Skip to content

Instantly share code, notes, and snippets.

@rgrove
Created November 22, 2010 18:44
Show Gist options
  • Save rgrove/710413 to your computer and use it in GitHub Desktop.
Save rgrove/710413 to your computer and use it in GitHub Desktop.
YUI.add('autocomplete-jeremy', function(Y) {
var Plugin = Y.Plugin;
function ACListPlugin(config) {
config.inputNode = config.host;
// Render by default.
if (!config.render && config.render !== false) {
config.render = true;
}
Y.before(this._bindPrompt, this, 'bindUI');
ACListPlugin.superclass.constructor.apply(this, arguments);
}
Y.extend(ACListPlugin, Y.AutoCompleteList, {
_bindPrompt: function () {
this.get('inputNode').on('focus', this._showLocationPrompt);
},
_showLocationPrompt: function (e) {
var inputNode = e.target;
if (inputNode.get('value') === '') {
this.get('listNode').setContent('<li>Please type the name of your city.</li>');
this.show();
}
}
}, {
NAME : 'autocompleteListPlugin',
NS : 'ac',
CSS_PREFIX: Y.ClassNameManager.getClassName('aclist')
});
Plugin.AutoComplete = ACListPlugin;
Plugin.AutoCompleteList = ACListPlugin;
}, '@VERSION@', {requires:['autocomplete-list', 'node-pluginhost']});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment