1 SLIVER_API = "/plstackapi/slivers/";
3 XOSCollection = Backbone.Collection.extend({
4 maybeFetch: function(options){
5 // Helper function to fetch only if this collection has not been fetched before.
7 // If this has already been fetched, call the success, if it exists
8 options.success && options.success();
9 console.log("alreadyFetched");
13 // when the original success function completes mark this collection as fetched
15 successWrapper = function(success){
18 success && success.apply(this, arguments);
21 options.success = successWrapper(options.success);
22 console.log("call fetch");
26 getOrFetch: function(id, options){
27 // Helper function to use this collection as a cache for models on the server
28 var model = this.get(id);
31 options.success && options.success(model);
44 this.sliver = Backbone.Model.extend({ urlRoot: SLIVER_API });
45 this.slivers = XOSCollection.extend({ urlRoot: SLIVER_API,
49 XOSLib = new xoslib();