Merge pull request #983 from ZogStriP/fix-combobox-not-working-properly

FIX: combobox were not working properly
This commit is contained in:
Robin Ward 2013-06-07 12:08:04 -07:00
commit cdc3a57a91
2 changed files with 8 additions and 8 deletions

View File

@ -71,7 +71,7 @@
{{#if email_digests}} {{#if email_digests}}
<div class='control-indent'> <div class='control-indent'>
{{combobox valueAttribute="value" content=digestFrequencies value="digest_after_days"}} {{combobox valueAttribute="value" content=digestFrequencies value=digest_after_days}}
</div> </div>
{{/if}} {{/if}}
<label>{{view Ember.Checkbox checkedBinding="email_private_messages"}} <label>{{view Ember.Checkbox checkedBinding="email_private_messages"}}
@ -88,12 +88,12 @@
<label class="control-label">{{i18n user.other_settings}}</label> <label class="control-label">{{i18n user.other_settings}}</label>
<div class="controls"> <div class="controls">
<label>{{i18n user.auto_track_topics}}</label> <label>{{i18n user.auto_track_topics}}</label>
{{combobox valueAttribute="value" content=autoTrackDurations value="auto_track_topics_after_msecs"}} {{combobox valueAttribute="value" content=autoTrackDurations value=auto_track_topics_after_msecs}}
</div> </div>
<div class="controls"> <div class="controls">
<label>{{i18n user.new_topic_duration.label}}</label> <label>{{i18n user.new_topic_duration.label}}</label>
{{combobox valueAttribute="value" content=considerNewTopicOptions value="new_topic_duration_minutes"}} {{combobox valueAttribute="value" content=considerNewTopicOptions value=new_topic_duration_minutes}}
</div> </div>
<div class="controls"> <div class="controls">

View File

@ -24,7 +24,7 @@ Discourse.ComboboxView = Discourse.View.extend({
if (this.get('content')) { if (this.get('content')) {
var comboboxView = this; var comboboxView = this;
return this.get('content').each(function(o) { this.get('content').each(function(o) {
var val = o[comboboxView.get('valueAttribute')]; var val = o[comboboxView.get('valueAttribute')];
if (val) { val = val.toString(); } if (val) { val = val.toString(); }
@ -44,12 +44,12 @@ Discourse.ComboboxView = Discourse.View.extend({
valueChanged: function() { valueChanged: function() {
var $combo = this.$(); var $combo = this.$();
var val = this.get('value'); var val = this.get('value');
if (val) { if (val !== undefined && val !== null) {
$combo.val(val.toString()); $combo.val(val.toString());
} else { } else {
$combo.val(null); $combo.val(null);
} }
$combo.trigger("liszt:updated") $combo.trigger("liszt:updated");
}.observes('value'), }.observes('value'),
didInsertElement: function() { didInsertElement: function() {
@ -66,12 +66,12 @@ Discourse.ComboboxView = Discourse.View.extend({
} }
if (this.classNames && this.classNames.length > 0) { if (this.classNames && this.classNames.length > 0) {
// Apply the classes to Chosen's dropdown div too: // Apply the classes to Chosen's dropdown div too:
this.classNames.each( function(c) { this.classNames.each(function(c) {
$elem.chosen().next().addClass(c); $elem.chosen().next().addClass(c);
}); });
} }
$elem.change(function(e) { $elem.chosen().change(function(e) {
comboboxView.set('value', $(e.target).val()); comboboxView.set('value', $(e.target).val());
}); });
} }