Sha256: 586bea138928195a1afd5da4d4ba1e049cab466f88cc48e609e800526205f8bd

Contents?: true

Size: 442 Bytes

Versions: 3

Compression:

Stored size: 442 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);
  }
});

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
backbone-support-0.3.1 lib/assets/javascripts/backbone-support/swapping_router.js
backbone-support-0.3.0 lib/assets/javascripts/backbone-support/swapping_router.js
backbone-support-0.2.0 lib/assets/javascripts/backbone-support/swapping_router.js