Posts

Showing posts from June, 2013

backbonejs' alteration of ajax handler parameters

As I spend time learning  Backbone  I've found some unexpected things (to me probably not to others). Today I found that even though  Backbone  fetch allows you to pass in typical jQuery  ajax  options (like success or error handlers), it will alter what parameters are passed back to those handlers. In jQuery Here is an example of plain jane ajax call (in older style jQuery before renaming of events): In backbone handler In backbone fetch changes up what you receive. It is nicely stated in that section: The  options  hash takes  success  and  error  callbacks which will both be passed  (collection, response, options)  as arguments. I only read that like 3 times before i actually saw that note :) Here is an example of backbone success handler: The one really nice part of the different parameters is that backbone gives you objects instead of raw-ish data. This means if you need to create two different models (or collections) from the same call, you can pass i