In my backbone project, my model is not updated after the 'add' method that I call in a Collection. I don't understand why.
I'm sure I'm doing something badly but I cannot figure what.
https://github.com/blured75/CardScores/blob/master/public/js/tweets.js
On the initialize function of my view, I call bind 'add' to this.render (of the view)
initialize: function() {
this.model.on('add', this.render, this);
},
In the render function of my view, this.model has no specific attributes, only {length: 1, models: Array(1), _byId: {…}, _events: {…}}
render: function() {
console.log('in render this.model', this.model);
...
}
The function used for the submit event of #new-tweet is well called and the tweet object is well populated :
The method $('#new-tweet').submit(function(ev) {
var tweet = new Tweet({ author: $('#author-name').val(), status: $('#status-update').val()});
console.log('adding : ', tweet.toJSON());
tweets.add(tweet);
return false;
});
Do you see something erroneous apart the fact of using an old framework ?