backbone.js - Best practice of binding models to backbone views -


i've following backbone model.

var credential = backbone.model.extend({     defaults: {     user: null,     password: null   } }); 

i want bind model view.

is best practice instantiate credential model router , pass view

var loginview = new loginview({ model: new credential() }); 

or instantiate model in initialize method of loginview.

var loginview = backbone.view.extend({     initialize: function() {       this.model = new credential();    } }); 

the best practice assign model view, not let view create model.

conceptually, view 1 representation of model, when can have multiple views representing same model (for instance form, , list).

this why keeping them loosely coupled , assigning model view better pattern.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -