I am in process of learning and using Backbone.js.
I have an Item model and a corresponding Item view. Each model instance has item_class and item_id attributes, that I
Try to assign the values in initialize method this will directly assign id and class to the div attribute dynamically.
var ItemView = Backbone.View.extend( {
tagName : "div",
id : '',
class : '',
initialize : function( options ) {
if ( ! _.isUndefined( options ) ) {
this.id = options.item_id;
this.class= options.item_class;
}
},
render : function() {
$( this.el ).html( this.template( "stuff goes here" ) );
}
} );