Created
August 14, 2010 00:25
-
-
Save ghinch/523772 to your computer and use it in GitHub Desktop.
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
YUI().use('widget-base', 'widget-stdmod', 'base-build', function (Y) { | |
var headerContent = '<a href="#" id="someButton">Click me</a>'; | |
var myWidget = Y.Base.create('my-widget', Y.Widget, [Y.WidgetStdMod], { | |
_headerButton : null, // ref to btn | |
renderUI : function () { | |
this.setStdModContent(Y.WidgetStdMod.HEADER, headerContent, Y.WidgetStdMod.REPLACE); | |
var header = this.getStdModNode(Y.WidgetStdMod.HEADER); | |
this._headerButton = header.one('#someButton'); // Returns null | |
}, | |
bindUI : function () { | |
if (this._headerButton) { // Fails, it doesn't exist | |
this._headerButton.on('click', function (e) { | |
e.preventDefault(); | |
}); | |
} | |
}, | |
syncUI : function () { | |
var header = this.getStdModNode(Y.WidgetStdMod.HEADER); | |
this._headerButton = header.one('#someButton'); // Here we can get it, but bind has already come and gone | |
} | |
}); | |
var myInstance = new myWidget(); | |
myInstance.render(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment