0
我的骨干视图如下所示,并使用jQuery tmpl库进行呈现。我想将样式应用于其中一个/所有/任何数据项,其中 活动== 1。任何想法如何做到这一点?Backbone&jQuery Tmpl - 将样式应用于模板项目
// backbone view
window.CaseView = Backbone.View.extend({
el: $("#main"),
initialize: function() {
_.bindAll(this, 'render');
this.render();
},
iTemplate: $("#tmplCase").template(),
render: function() {
var that = this;
that.el.fadeOut('fast', function() {
$.tmpl(that.iTemplate, that.model.toJSON()).appendTo(that.el);
that.el.fadeIn('fast');
});
return this;
}
});
// html file
<div id="main"></div>
<script id="tmplCase" type="text/x-jquery-tmpl">
<div class="caseInActive">
<span class="title">${title}</span>
<span class="current_status">${active}</span>
</div>
</script>
感谢,这种做法并没有涌现在脑海中的。 – Joe 2011-08-17 14:13:21