Thursday, 15 July 2010

Render callback to all templates in meteor blaze -



Render callback to all templates in meteor blaze -

i forced assign rendered callbacks templates.

until 0.9.0 used this:

_.each( template, function( template, name ) { //... template.rendered = function() { //... }; });

but now, template constructor , not object, method won't work here. there way pass callback function templates or fire function when templates rendered using blaze?

here quick workaround came with, iterating on every template property find out if corresponds template definition, , if does, assign onrendered callback.

// create sure code executed after templates have been defined meteor.startup(function(){ for(var property in template){ // check if property blaze template if(blaze.istemplate(template[property])){ var template=template[property]; // assign template onrendered callback prints view name template.onrendered(function(){ console.log(this.view.name); }); } } });

i don't know what's utilize case there may improve solutions depending on it.

meteor meteor-blaze

No comments:

Post a Comment