Last active
December 13, 2015 17:09
-
-
Save thecountofzero/4945394 to your computer and use it in GitHub Desktop.
IsReady Support For Controls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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