Skip to content

Instantly share code, notes, and snippets.

@lcmen
Last active June 27, 2017 11:28
Show Gist options
  • Save lcmen/7055550 to your computer and use it in GitHub Desktop.
Save lcmen/7055550 to your computer and use it in GitHub Desktop.
[Backbone: base Marionette controller] Base controller that I use in my marionette.js applications. #tags: backbone.js
Controller.Base = function() {
function Controller(options) {
options = options || {};
this.region = options.region;
Marionette.Controller.call(this, options);
}
Controller.extend = Marionette.Controller.extend;
_.extend(Controller.prototype, Marionette.Controller.prototype);
_.extend(Controller.prototype, {
show: function(view) {
this.listenTo(view, 'close', this.close);
this.region.show(view);
},
close: function() {
Marionette.Controller.prototype.close.call(this);
}
});
return Controller;
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment