FIX: handle enter key with a better way on site setting string inputs

This commit is contained in:
Neil Lalonde 2014-07-15 17:32:27 -04:00
parent f2dd35ab08
commit 823061a2cf

View file

@ -24,11 +24,9 @@ Discourse.SiteSettingView = Discourse.View.extend(Discourse.ScrollTop, {
}.property('content.type'), }.property('content.type'),
didInsertElement: function() { _watchEnterKey: function() {
var self = this; var self = this;
this._super(); this.$().on("keydown.site-setting-enter", ".input-setting-string", function (e) {
Em.run.schedule('afterRender', function() {
self.$('.input-setting-string').keydown(function(e) {
if (e.keyCode === 13) { // enter key if (e.keyCode === 13) { // enter key
var setting = self.get('content'); var setting = self.get('content');
if (setting.get('dirty')) { if (setting.get('dirty')) {
@ -36,7 +34,10 @@ Discourse.SiteSettingView = Discourse.View.extend(Discourse.ScrollTop, {
} }
} }
}); });
}); }.on('didInsertElement'),
}
_removeBindings: function() {
this.$().off("keydown.site-setting-enter");
}.on("willDestroyElement")
}); });