JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.10/backbone-min.js"></script>
JavaScript
var Book = Backbone.Model.extend({
rootUrl: '/book'
}),
BooksCollection = Backbone.Collection.extend({
model: Book,
url: '/books',
sync: function (method, model, options) {
//for read operations, call the search url
if (method === 'read') {
options.url = '/search/' + options.data.name;
delete options.data.name;
}
//call the default sync implementation
return Backbone.Collection.prototype.sync.apply(this, arguments);
}
}),
books = new BooksCollection();
books.fetch({data : {name: 'life'}});