Created
July 7, 2011 19:50
-
-
Save ColinCampbell/1070383 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // ========================================================================== | |
| // Project: HF - Select | |
| // Copyright: ©2011 Strobe Inc. | |
| // ========================================================================== | |
| /*globals Hellfire HF */ | |
| /** | |
| @class | |
| @extends SC.TemplateCollectionView | |
| */ | |
| HF.Select = SC.TemplateCollectionView.extend( | |
| /** @scope HF.Select.prototype */ { | |
| attributeBindings: ['selected'], | |
| tagName: 'select', | |
| value: function(key, value) { | |
| var elemQuery = this.$(); | |
| if (value !== undefined) { | |
| if (this._value !== value || elemQuery.val() !== value) { | |
| this._value = value; | |
| elemQuery.val(value); | |
| } | |
| } else { | |
| if (elemQuery.length > 0) { | |
| value = this._value = elemQuery.val(); | |
| } else { | |
| value = this._value; | |
| } | |
| } | |
| return value; | |
| }.property().idempotent(), | |
| didCreateLayer: function() { | |
| var elemQuery = this.$(), | |
| self = this; | |
| elemQuery.val(this._value); | |
| elemQuery.bind('change', function() { | |
| self.domValueDidChange(); | |
| }); | |
| }, | |
| domValueDidChange: function() { | |
| var elemQuery = this.$(); | |
| this.set('value', elemQuery.val()); | |
| }, | |
| itemViewClass: SC.TemplateView.extend({ | |
| attributeBindings: ['label', 'value'], | |
| tagName: 'option' | |
| }) | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment