jquery - Re-executing Javascript every route in Meteor / Flow Router? -


i have code in theme appends background css background. here's js code:

$('.background-image-holder').each(function() {     var imgsrc = $(this).children('img').attr('src');     $(this).css('background', 'url("' + imgsrc + '")');     $(this).children('img').hide();     $(this).css('background-position', 'initial'); });  // fade in background images  settimeout(function() {     $('.background-image-holder').each(function() {         $(this).addclass('fadein');     }); }, 200); 

now issue code works everytime refresh page, not when click 1 route next.

e.g. refresh index page , cover image loads, if click page images on page no longer load... unless refresh page. i'm executing code using .onrendered method:

template.mainindex.onrendered(function(){ ...code here }); 

is there anyway can have script re-execute on every load, or there better way resolve issue? i'm using flow router, , blaze layout on meteor js.

flowrouter has triggers: https://github.com/kadirahq/flow-router#triggers

flowrouter.triggers.enter([cb1, cb2]); flowrouter.triggers.exit([cb1, cb2]); 

Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -