Sha256: b02765792ff2c4ac2846f875ea6d59f58d189d6dc0149260b75f57f0c6ce04d0

Contents?: true

Size: 1.76 KB

Versions: 3

Compression:

Stored size: 1.76 KB

Contents

exoskeleton.collections.base_collection = Backbone.Collection.extend({

  __fetchStatus: new exoskeleton.models.load_status,

  fetchStatus: function(){
    return this.__fetchStatus
  },

  parse: function(response){
    return response.data
  },

  fetch: function(options){
    var _this = this ;
    this.__fetchStatus = new exoskeleton.models.load_status()
    Backbone.Collection.prototype.fetch.call(this,{
      success: function(collection, response){
        if(response.success == undefined){
          _this.trigger('fetch:unsuccessful', collection, null, null)
          alert("Response did not come back in appropriate json format needed: {success: [true/false], data: [Your Data], message: [Custom Message]")
          return
        }
        _this.__fetchStatus.set_completed()
        _this.__fetchStatus.set_message(response.message)
        if(response.success){
          _this.__fetchStatus.set_successful()
          _this.trigger('fetch:successful', collection, response.data, response.message)
        } else {
          _this.trigger('fetch:unsuccessful', collection, response.data, response.message)
        }
        if(options && options.success){
          options.success(collection, response)
        }
        _this.trigger('fetch:complete', collection, response.data, response.message)
      },
      error: function(collection, response) {
        _this.__fetchStatus.set_completed()
        _this.__fetchStatus.set_message(response.message)
        _this.__fetchStatus.set_system_error()
        _this.trigger('fetch:error', collection, response.data, response.message)
        if(options && options.error){
          options.error(collection, response)
        }
        _this.trigger('fetch:complete', collection, response.data, response.message)
      }
    })
  }

})

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
exoskeleton-0.0.6 app/assets/javascripts/exoskeleton/collections/base_collection.js
exoskeleton-0.0.5 app/assets/javascripts/exoskeleton/collections/base_collection.js
exoskeleton-0.0.4 app/assets/javascripts/exoskeleton/collections/base_collection.js