harvesthq/chosen — pull request #1464 by viperdezigns (2013-08-09 17:03:22+00:00)
Title: Adding YUI 3.10.3 Port to Chosen Plugin

Full port of jQuery Chosen to YUI 3. Tested on YUI 3.10.3, anything above YUI 3.5 should work to the best of my knowledge. If there is anything that needs to be changed, let me know.

The purpose of this YUI Port is simple. Node Events do not bubble to YUI when using the jQuery's Chosen. Makes it impossible to listen for Y_Node.on('change') event. Using the $().chosen().change() event presents issues when listening on YUI's Global Namespace.

USAGE EXAMPLE:
YUI().use('node','yui-chosen', function(Y) {
Y.all('.yui-chosen').each(function(ele) {
ele.plug(Y.Chosen, {
no_results_text: "Nothing found dummy.",
disable_search_threshold: 4,
max_selected_options: 2,
allow_single_deselect: true,
width: "500px"
});
ele.on('change', function(e) {
var value = null;
if (e.currentTarget.getDOMNode().type == 'select-multiple') {
var value = [];
e.currentTarget.all('option').each(function(opt) {
if (opt.get('selected')) {
value.push(opt.get('value'));
}
});
} else {
value = e.currentTarget.get('value');
}
});
});
});