Note that there are some explanatory texts on larger screens.

plurals
  1. POBackbone.js view not rendering
    primarykey
    data
    text
    <p>On my Backbone app, one of the views is not rendering as expected.</p> <p>When a user follows the route 'test/addtests', it calls a function which is shown below</p> <pre><code>addtests: function () { this.testView = new TestView(); }, </code></pre> <p>The view should then automatically render using the initialize function show below</p> <pre><code>window.TestView = Backbone.View.extend({ template: _.template($('#test').html()), initialize: function () { tests.bind("reset", this.render, this); }, render: function (eventName) { alert('asdf'); $(this.el).html(this.template()); _.each(tests.models, function (test) { this.renderSelectBox(test); }, this); return this; }, renderSelectBox: function (test) { var optionView = new TFS.FormOptionView({ model: test }); $(this.el).append(optionView.render().el); }, events:{ "click button": "addTest" }, ...ect }); </code></pre> <p>However nothing happens, it simply displays content from the last page. The alert I set up in the render function does not fire either. However oddly, if I click refresh, the alert fires :S.</p> <p>The route is set up right, and correctly points to the 'addtests' function, it seems that it just is not initialising the view as expected.</p> <p>Also a second thing I have found confusing is if I have a full collection, I am unable to use the get method to pull a single modle out. For example</p> <pre><code>players // a full collection var test = players.get(1); console.log(test.get('id')); //undefined </code></pre> <p>:S</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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