FIX: The previous flag reason was selected when opening the modal.

This commit is contained in:
Robin Ward 2013-07-22 12:05:13 -04:00
parent e73c809836
commit 112b9f9c2a
2 changed files with 12 additions and 11 deletions

View File

@ -9,6 +9,10 @@
**/ **/
Discourse.FlagController = Discourse.ObjectController.extend(Discourse.ModalFunctionality, { Discourse.FlagController = Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
onShow: function() {
this.set('selected', null);
},
changePostActionType: function(action) { changePostActionType: function(action) {
this.set('selected', action); this.set('selected', action);
}, },

View File

@ -11,18 +11,15 @@ Discourse.FlagView = Discourse.ModalBodyView.extend({
title: I18n.t('flagging.title'), title: I18n.t('flagging.title'),
selectedChanged: function() { selectedChanged: function() {
var nameKey = this.get('controller.selected.name_key'); var flagView = this;
if (!nameKey) return;
Em.run.next(function() { Em.run.next(function() {
$('#radio_' + nameKey).prop('checked', 'true'); flagView.$("input[type='radio']").prop('checked', false);
});
}.observes('controller.selected.name_key'),
didInsertElement: function() { var nameKey = flagView.get('controller.selected.name_key');
this._super(); if (!nameKey) return;
flagView.$('#radio_' + nameKey).prop('checked', 'true');
});
}.observes('controller.selected.name_key')
// Would be nice if there were an EmberJs radio button to do this for us. Oh well, one should be coming
// in an upcoming release.
this.$("input[type='radio']").prop('checked', false);
}
}); });