在我的 Backbone 视图中,我正在设置标记名、类名、临时值。除了类名之外,所有这些都可以正常工作。
我如何设置类名..或者我的代码有什么错误..
define(["singleton","listCollection","listModel"],function(singleton,collection,listModel){
singleton.view = Backbone.View.extend({
tagName :'article',
className :'indBoard',
projectName : true,
template0 : _.template($('#listTemplate').html()),
template1 : _.template($('#boardTemplate').html()),
initialize :function(options){
this.template = this['template'+options.tempNo];
this.tagName = options.tagName;
//i am changing to 'li' works
this.className = options.cName;
//changing to new class name not working
console.log(options.cName);//consoles new class name properly
this.projectName = options.subTempNo == 0 ?true:false;
//condition as well works..
},
render:function(){
var temp = this.template;
this.$el.html(temp(this.model.toJSON()));
return this;
}
});
return singleton.view;
});