Search code examples
backbone.jsbackbone-eventsbackbone.js-collections

What was the nature of the Backbone collection sync event?


If one set's a event listeners on a Backbone collection's sync event, how can it be determined from the event listener what the nature of the sync was: was it an updated? a new model was added to the collection or was actually deleted?

At the fist glance the information about the completed xhr request that is being returned to the listener does not contain the HTTP method used with that sync (get, put, post or delete).


Solution

  • You can override the sync() method for the collection instead of triggering on the completion event. If that's doable, the methodparameter will tell you the type of sync required.