Skip to content

Instantly share code, notes, and snippets.

@voloko
Created February 15, 2010 11:47
Show Gist options
  • Save voloko/304580 to your computer and use it in GitHub Desktop.
Save voloko/304580 to your computer and use it in GitHub Desktop.
uki.view.NativeSelect = uki.newClass(uki.view.Base, new function() {
var Base = uki.view.Base.prototype,
proto = this, emptySelectSize = {};
proto.typeName = function() { return 'uki.view.NativeSelect'; };
proto._createDom = function() {
this._dom = uki.createElement('select', Base.defaultCss);
};
uki.delegateProp(proto, 'disabled', '_dom');
uki.delegateProp(proto, 'value', '_dom');
uki.delegateProp(proto, 'selectedIndex', '_dom');
proto.options = function(val) {
if (val === undefined) return uki.map(this._dom.getElementsByTagName('option'), function(option) {
return { value: option.getAttribute('value'), html: option.innerHTML };
});
this._dom.innerHTML = '';
uki.each(val, function(i, option) {
var node = uki.createElement('option', '', option.html);
node.value = option.value;
this._dom.appendChild(node);
// return ['<option value="', uki.escapeHTML(option.value || '') ,'">', option.html || '' ,'</option>'].join('');
}, this);
};
});
uki.Collection.addAttrs('options');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment