Skip to content

Instantly share code, notes, and snippets.

@thecountofzero
Last active December 13, 2015 17:09
Show Gist options
  • Save thecountofzero/4945394 to your computer and use it in GitHub Desktop.
Save thecountofzero/4945394 to your computer and use it in GitHub Desktop.
IsReady Support For Controls
steal('can/control',
'can/construct/super', function() {
window.MyApp = window.MyApp || {};
window.MyApp.Controls = window.MyApp.Controls || {};
window.MyApp.Controls.BaseControl = can.Control({
defaults: {}
}, {
setup: function(htmlElement, rawOptions) {
// A deferred so that components that invoke this controller can know when it has completed initializing
this._deferred = can.Deferred();
// Make sure we call can.Control's setup (which way is better?)
//return this._super.apply(this, arguments);
return can.Control.prototype.setup.apply(this, arguments);
},
/**
* Returns the deferred that allows components to know when the control is ready (done initializing)
*
* @returns $.Deferred.promise
*/
isReady: function() {
return this._deferred.promise();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment