Note that there are some explanatory texts on larger screens.

plurals
  1. POBackbone.js - reset not triggering the render function
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/14460449/backbone-js-add-parameter-sending-to-fetch-not-trigger-the-collection">Backbone.js - add parameter sending to fetch not trigger the collection</a> </p> </blockquote> <p>In my function, eventhough i added the reset to trigger my render function, nothing is happening... any clue me the wrong what i did..?</p> <p>code:</p> <pre><code>$(document).ready(function(){ var school = {}; school.model = Backbone.Model.extend({ defaults:{ name:'name yet to decide' } }); school.collect = Backbone.Collection.extend({ model:school.model, url:'js/school.json', parse:function(response){ return response; } }); school.view = Backbone.View.extend({ tagName:'div', className:'division', template:$('#newTemp').html(), render:function(){ var temp = _.template(this.template); this.$el.html(temp(this.model.toJSON())); return this; } }); school.views = Backbone.View.extend({ el:$('#content'), initialize:function(){ _.bindAll(this); this.collection = new school.collect; this.collection.bind("reset", this.render); this.collection.fetch({ update:true }) }, render:function(){ var that = this; _.each(this.collection.models, function(item){ that.addItems(newItem); }) }, resets:function(){ console.log(this.collection.models) console.log('calling from resets') }, addItems:function(item){ var newItem = new school.collect({model:item}); this.$el.append(newItem.render().el); }, changed:function(){ console.log('calling from changed') } }); var newSchool = new school.views; }) </code></pre>
    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.
 

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