Hello,

there is overridden collection fetch function.

fetch: function() {

        var collection = this;

       $.getJSON(this.url, function(data) {


              // do some processing to data here


          collection.reset(data);
       });
    },

I need to do processing when I get data, so thats why overrride. But the thing - is - the models change event is not triggered, here ,so models do not see and do not render.

I could call proably render method in the getJSON callback but its not they way it should be I guess. How to make here model change event?

in the view class initialize method I did this

this.listenTo(Cars, 'reset', this.addAll); 

addOne: function(car) {

  var view = new CarView({model: car});

  this.$("#cars").append(view.render().el);
},

// Add all items in the **Cars** collection at once.
addAll: function() {
  Cars.each(this.addOne, this);
},

so the reset is triggered when I called reset method in the fetch. View listens to reset and creates view items and draws them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.