Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Backbone already supports overriding this in several ways:

1. You can pass any arguments to the ajax call in the options hash passed to the various calls:

    Foo = Backbone.Model.extend({url: "/bar" })
    f = new Foo
    f.fetch({type: "BLAH"}) 

    leads to a "BLAH /bar" request instead of a GET.
2. You can override Backbone.sync to do an application-wide override. The basic implementation is fairly simple as a starting point and/or you can just wrap it.

3. You can override the sync methods of Backbone.Model or Backbone.Collection. By default these just proxy to Backbone.sync

4. You can extend either of them and derive your own models and collections from your extended version.

5. You can replace .sync for any _specific_ model or collection object if you have specific sync needs for specific subsets of your application.

Given this, I really don't think cluttering the default code with more options is worthwhile - any other variations would be better provided for by providing an alternate implementation which can optionally proxy to the default/original for cases that doesn't need special handling.

This is part of what I like about Backbone - it is small and focused and sufficiently decoupled that replacing parts of the guts of it is simple to do.



Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: