backbone.js - Using same object instance from more than one different Backbone/Require views -
I try to write the login view of two scenes and try to render each data with the same data as The two are collected from a pool domain in both. The log template has a low data field, so the template template variables in comparison to the template template.
So I thought of using a model for both of them to render the GUI, the data model formats, I am trying to isolate worries and to keep single responsibility for my module. Now, the form data model needs to make the dependence of a scene and make it in this view, and by looking at this dependence of this second example, mention this example from another example. Yet for the last time it should use the same example of seeing it, it is in the form of dependence it seems that there is only one scene and three different model data, login and registration and two separate templates are a solution You can.
It looks amazing in the object-oriented paradigm that it feels cumbersome to add a small feature, which fights with object orientation ideas. All this feature is for the time when the user clicks on the register button in the login view, just presents the register view with the registered data and vice versa.
To use it, its models, etc. to refer to a scene / model from the second scene, the wrong use of the backbone is necessary or necessary, whereas they are good development practices such as separating concerns, singles Responsibility, and modularisation isolation, or is it not bad at all about those good dev practices?
I do not believe this is a "false" copy that says View1
Depends on View2
so that View1
creates a model
that view2
... but I think this sub Optimal I can think of two other strategies you might want to consider which will depend on View1
depending on View2
.
First, you can not choose View2 in
Em> create . .. and create in your module already. In other words: model
, and instead <2> create
// define thelogin.data.js (['log-in data'], function (log-in data) {new login data ();}); // View # 2 define (['the login data'], function (login data) {return bb.on. view.extension ({some method: function) {theLoginData.set (whatever);}});}); // View # 1 define (['the login data'], function (login data) {return babon view.extension ({some other method: function} {var whatever = theLoginData.get ('whatever');} }}}};
The second option can still create a model
in View2, but it can be used in more global scope (e.g., models
Class which you use for your login data model
):
// login data.es (i.e. the model class for your login data) defined ([ ], Define View # 2 (['log-in data'], function (log-in data) {return backbone.view.} {Backbone.Model.extend ({}, {currentLoginData: null})}}; Extensions ({Some Method: Function () (Login ['Log-In Data'], Function (Log-InData) (Log-In dataContentGuardData = New LoginData (whatever);}});}); {Return backbone view.extension ({some other method: function} {var whatever = login data. Login.data ('whatever');}});});
Comments
Post a Comment