Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ul> <li>Normally model instances should be passed to views in the <code>options</code> argument to the <code>initialize</code> method.</li> </ul> <p>Generally models represent data that either is currently or will eventually be stored in database somewhere. Now, sometimes you want to create a model just for managing ephemeral browser state, which is fine, but the common case is that most read/edit/delete views don't create models unless that's their primary purpose like a "Post New Comment" form. So normally if your view has to show some models, allow them maybe to be updated and saved, they should come into the view in the <code>options</code> argument to the <code>initialize</code> function.</p> <p>However, if your view really needs so many models and nothing else in your system cares about them, just create them during <code>initialize</code> and store them directly as properties on <code>this</code> (your view instance) and off you go.</p> <p>If you post a more complete code sample, we can give specific recommendations, but as it is it looks like if you have a <code>LoginView</code> and you need more than 1 model for it, you might be off in the weeds design-wise.</p> <p><strong>Part Deux</strong></p> <p>OK, so it looks like you think every API endpoint needs a model. Just implement those as methods on a single model class that use <code>Backbone.sync</code> with the appropriate <code>url</code> option.</p> <pre><code>var Model = Backbone.Model.extend({ resendActivation: function () { return Backbone.sync.call('update', this, {url: fn_helper.restDomain()+ 'user/token/activation/new'}); } }); </code></pre> <p>You may have to do some manual triggering of events and I'm not sure what your API returns, but fundamentally these are all dealing with a single user record and can be handled by a single model.</p> <p>Misc unrelated tips:</p> <ul> <li><code>_.bindAll(this);</code> //don't bother listing methods out</li> <li><code>this.model.on('reset change', this.render);</code> //bind multiple events at once</li> <li>JavaScript by vast majority convention use camelCase not lower_with_underscores</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload