To learn backbone Im creating a Twitter like app. So you know that Twitter sends a GET request to the server every N seconds to check for new tweets. If there are new tweets
create
is still asynchronous even if you pass { wait: true }
. The difference is without wait
the model will get added to the collection immediately while with wait
backbone won't add it to the collection until a success response from the server.
What you should do is add a success callback to create
that fires the event upon the server response.
var created_tweet = this.collection.create( newTweet, { silent: true, wait: true, success: this.successCallback } );
// Add successCallback as a method to the collection
successCallback: function(collection, response) {
// I'm not 100% positive which values are passed to this function. Collection may actually be the new model.
this.collection.trigger("posted_new_tweet", created_tweet);
}