Skip to content

Instantly share code, notes, and snippets.

@ptomasroos
Forked from jstrimpel/gist:ce9e91952745834ab050
Last active August 29, 2015 14:06
Show Gist options
  • Save ptomasroos/17f8f957095e89f6ab9e to your computer and use it in GitHub Desktop.
Save ptomasroos/17f8f957095e89f6ab9e to your computer and use it in GitHub Desktop.
// base controller
define(['lazoCtl'], function (Ctl) {
'use strict';
return Ctl.extend({
index: function (options) {
this.loadModel('session', {
success: function (model) {
this.ctx.models.session = model;
// the extended controller could set a property
// enabling you to call any view from the base
options.success(this.action || 'index');
},
error: function (options) {
// handle error
}
});
}
});
});
// extend base controller
// you could use another controller or the lazo
// base controller; the main point is that
// you eventually call BaseCtl.prototype.index
define(['app/baseCtl'], function (BaseCtl) {
'use strict';
return BaseCtl.extend({
index: function (options) {
// execute code specific to this controller
// then call base controller index action
BaseCtl.prototype.index.call(this, options);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment