Sha256: 972c236080392cda46541390eab0a30d0f3dc319259bb1258d7ffb403246d2f7

Contents?: true

Size: 539 Bytes

Versions: 2

Compression:

Stored size: 539 Bytes

Contents

Support.SwappingRouter = function(options) {
  Backbone.Router.apply(this, [options]);
};

_.extend(Support.SwappingRouter.prototype, Backbone.Router.prototype, {
  swap: function(newView) {
    if (this.currentView && this.currentView.leave) {
      this.currentView.leave();
    }

    this.currentView = newView;
    $(this.el).empty().append(this.currentView.render().el);

    if (this.currentView && this.currentView.swapped) {
      this.currentView.swapped();
    }
  }
});

Support.SwappingRouter.extend = Backbone.Router.extend;

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
backbone-support-0.4.0 lib/assets/javascripts/backbone-support/swapping_router.js
backbone-support-0.3.2 lib/assets/javascripts/backbone-support/swapping_router.js