From 823061a2cff3a28540b5cb12bb28191b030e93cb Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Tue, 15 Jul 2014 17:32:27 -0400 Subject: [PATCH] FIX: handle enter key with a better way on site setting string inputs --- .../admin/views/site_setting_view.js | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/admin/views/site_setting_view.js b/app/assets/javascripts/admin/views/site_setting_view.js index 37b724a65fb..f7e9554427b 100644 --- a/app/assets/javascripts/admin/views/site_setting_view.js +++ b/app/assets/javascripts/admin/views/site_setting_view.js @@ -24,19 +24,20 @@ Discourse.SiteSettingView = Discourse.View.extend(Discourse.ScrollTop, { }.property('content.type'), - didInsertElement: function() { + _watchEnterKey: function() { var self = this; - this._super(); - Em.run.schedule('afterRender', function() { - self.$('.input-setting-string').keydown(function(e) { - if (e.keyCode === 13) { // enter key - var setting = self.get('content'); - if (setting.get('dirty')) { - setting.save(); - } + this.$().on("keydown.site-setting-enter", ".input-setting-string", function (e) { + if (e.keyCode === 13) { // enter key + var setting = self.get('content'); + if (setting.get('dirty')) { + setting.save(); } - }); + } }); - } + }.on('didInsertElement'), + + _removeBindings: function() { + this.$().off("keydown.site-setting-enter"); + }.on("willDestroyElement") });