torso-bundle.js
function(fetchMethod, options) {
        var object = this;
        this.loadingCount++;
        this.loading = true;
        this.trigger('load-begin');
        return $.when(fetchMethod.call(object, options)).always(function() {
          if (!object.loadedOnce) {
            object.loadedOnce = true;
            object.loadedOnceDeferred.resolve();
          }
          object.loadingCount--;
          if (object.loadingCount <= 0) {
            object.loadingCount = 0; // prevent going negative.
            object.loading = false;
          }
        }).done(function(data, textStatus, jqXHR) {
          object.trigger('load-complete', {success: true, data: data, textStatus: textStatus, jqXHR: jqXHR});
        }).fail(function(jqXHR, textStatus, errorThrown) {
          object.trigger('load-complete', {success: false, jqXHR: jqXHR, textStatus: textStatus, errorThrown: errorThrown});
        });
      }
function(fetchMethod, options) {
        var object = this;
        this.loadingCount++;
        this.loading = true;
        this.trigger('load-begin');
        return $.when(fetchMethod.call(object, options)).always(function() {
          if (!object.loadedOnce) {
            object.loadedOnce = true;
            object.loadedOnceDeferred.resolve();
          }
          object.loadingCount--;
          if (object.loadingCount <= 0) {
            object.loadingCount = 0; // prevent going negative.
            object.loading = false;
          }
        }).done(function(data, textStatus, jqXHR) {
          object.trigger('load-complete', {success: true, data: data, textStatus: textStatus, jqXHR: jqXHR});
        }).fail(function(jqXHR, textStatus, errorThrown) {
          object.trigger('load-complete', {success: false, jqXHR: jqXHR, textStatus: textStatus, errorThrown: errorThrown});
        });
      }
function ( fetchMethod , options ) { var object = this ; this . loadingCount ++ ; this . loading = true ; this . trigger ( 'load-begin' ) ; return $ . when ( fetchMethod . call ( object , options ) ) . always ( function ( ) { if ( ! object . loadedOnce ) { object . loadedOnce = true ; object . loadedOnceDeferred . resolve ( ) ; } object . loadingCount -- ; if ( object . loadingCount <= 0 ) { object . loadingCount = 0 ; // prevent going negative. object . loading = false ; } } ) . done ( function ( data , textStatus , jqXHR ) { object . trigger ( 'load-complete' , { success : true , data : data , textStatus : textStatus , jqXHR : jqXHR } ) ; } ) . fail ( function ( jqXHR , textStatus , errorThrown ) { object . trigger ( 'load-complete' , { success : false , jqXHR : jqXHR , textStatus : textStatus , errorThrown : errorThrown } ) ; } ) ; }
Base load function that will trigger a "load-begin" and a "load-complete" as
the fetch happens. Use this method to wrap any method that returns a promise in loading events
@method __loadWrapper
@param fetchMethod {Function} - the method to invoke a fetch
@param options {Object} - the object to hold the options needed by the fetchMethod
@return {Promise} a promise when the fetch method has completed and the events have been triggered
Base load function that will trigger a load - begin and a load - complete as the fetch happens . Use this method to wrap any method that returns a promise in loading events