
Untitled
By: a guest on
Apr 28th, 2012 | syntax:
None | size: 0.78 KB | hits: 15 | expires: Never
SC.Select = SC.CollectionView.extend({
tagName: 'select',
value: '',
itemViewClass: SC.View.extend({
tagName: 'option',
displayProperty: false,
valueProperty: false,
applyAttributesToBuffer: function(buffer){
if (this.get('valueProperty')) {
buffer.attr('value', this.get('content')[this.valueProperty]);
}
return this._super(buffer);
},
displayValue: function(){
return this.get('content')[this.displayProperty];
}.property('content'),
defaultTemplate: SC.Handlebars.compile('{{displayValue}}')
}),
change: function() {
SC.run.once(this, this._updateSelection);
return false;
},
_updateSelection: function() {
var selection = this.$('option:selected');
SC.set(this, 'value', selection.prop('value'));
}
});