Meteor:在每次“更改"时执行 jQuery 代码 [英] Meteor: execute jQuery code on every "change"
问题描述
我有一个应用程序,每次我的页面"更改时,我都想在某些 DIV
框上执行 jQuery equalize()
函数.目前,我在主布局的 render()
函数中有代码,但它仅在用户重新加载整个页面时执行.我尝试使用 autorun
但这也没有用.
I have an app where I want to execute a jQuery equalize()
function on some DIV
boxes every time my "pages" change. At the moment I have the code inside my main layout's render()
function but it is executed only once the user reloads the whole page. I tried to use autorun
but this didn't work out either.
Meteor 1.0.3.1 + iron:router
Meteor 1.0.3.1 + iron:router
我有不同的页面视图和路由(例如/home、/about-us、/terms、...),一旦用户导航到一个页面(意思是跟随一个路由到另一个视图),代码应该被执行.
I have different page views with routes (e.g. /home, /about-us, /terms, ...) and once the user navigates to a page (meaning follows a route to another view) the code should be executed.
推荐答案
如果您使用的是 铁路由器,然后试试这个:
If you are using iron-router, then try this:
Router.onAfterAction(
function(){
// select divs and apply equalize
},
{
only: ['admin']
// or except: ['routeOne', 'routeTwo']
}
);
这篇关于Meteor:在每次“更改"时执行 jQuery 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!