1

How do i have some default property in ItemView or Layout in Backbont.Marionette.js.

we have the default property in model like the following .

Backbone.Model.extend({
       defaults: {
            contract:"",

        }
    });

in the above model we have defaults to have some default properties. Can we have something similar in ItemView or Layout

One should be able to change the value for the defaults which are specified in Itemview or Layout

4

1 回答 1

1

You can create defaults by specifying them in the view classes that you make. For example;

var MyView = Backbone.Marionette.Composite.extend({
    defaults:{
        something: "value"
    }
});

Now all instances of MyView will have these defaults

var view = new MyView({
    initialize: function(){
        var x = this.defaults.something; //x = "value"
    }
);
于 2013-08-19T10:31:47.237 回答