A Backbone.js Playground
a playground setup with includes of backbone, jquery, underscore,...
HTML
<script src="http://documentcloud.github.com/underscore/underscore.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone.js"></script>
JavaScript
var App = {};
App.ChartPointList = Backbone.Collection.extend({
model: App.ChartPoint,
url: function() {
return '/chartpoints/' + this.userConceptId;
},
fetch: function(userConceptId, options) {
console.log("fetch chart point");
typeof(options) != 'undefined' || (options = {});
options.success = this.postProcess;
options.error = this.handleError;
this.userConceptId = userConceptId;
return Backbone.Collection.prototype.fetch.call(this, options);
},
postProcess : function (resp, status, xhr) {
alert("I'm the success callback");
},
handleError : function (resp, status, xhr) {
alert("I'm the error callback : " + xhr);
}
});
var charPointList = new App.ChartPointList();
charPointList.fetch("wadus");