我正在尝试向一个 DOM 元素添加一个类,该元素是我所有 DOM 树的父级。我尝试了不同的方法:
//this one doesn't work at all. DOM is not loaded
Template.home.created = function() {
Meteor.startup(function() {
$("#wrapper").addClass('app');
});
}
//this one only works if you do a page load, not if you render the template through a link (using router)
Template.home.created = function() {
Meteor.startup(function() {
$(document).ready(function() {
$("#wrapper").addClass('app');
});
});
}
//also does not work if I click on a link
Template.home.created = function() {
$(document).ready(function() {
$("#wrapper").addClass('app');
});
}
//does not work at all (I really expected this one to work by clicking on a link (using router))
Template.home.created = function() {
$("#wrapper").addClass('app');
});
}
我要做的再简单不过了:添加一个类,以便我可以根据每个模板设置我的包装器样式。任何有关如何执行此操作的建议将不胜感激。