1.

Can You Have Default Values For Model? If Yes, How?

Answer»

Yes, we can set default VALUES for the MODEL ATTRIBUTES.

See the example below:

MyClass = Backbone.Model.extend({
defaults: { //SETS default values
attrib1: 'Default Attribute1 Value',
attrib2: 0
},
initialize: function(){
alert("It is so easy to set default values. Isn't it?");
}
});

Yes, we can set default values for the model attributes.

See the example below:

MyClass = Backbone.Model.extend({
defaults: { //sets default values
attrib1: 'Default Attribute1 Value',
attrib2: 0
},
initialize: function(){
alert("It is so easy to set default values. Isn't it?");
}
});



Discussion

No Comment Found