From 6e241b841184c0e23c8eeb4a3766e06f858934bc Mon Sep 17 00:00:00 2001 From: Ashutosh Dhundhara Date: Sat, 12 Apr 2014 02:37:42 +0530 Subject: [PATCH] Bug Fix: #4357 JS Form is sumitted on "enter" even if focus is inside a select field. Signed-off-by: Ashutosh Dhundhara Removed TODO tag from comment in rte.js Signed-off-by: Ashutosh Dhundhara --- js/functions.js | 26 ++++++++++++++------------ js/rte.js | 2 -- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/js/functions.js b/js/functions.js index ba9a89c212..448bc39622 100644 --- a/js/functions.js +++ b/js/functions.js @@ -872,7 +872,7 @@ function addDateTimePicker() { var timeFormat = 'HH:mm:ss'; // check for decimal places of seconds if (($(this).parent().data('decimals') > 0) && ($(this).parent().data('type').indexOf('time') != -1)){ - showMillisec = true; + showMillisec = true; timeFormat = 'HH:mm:ss.lc'; if ($(this).parent().data('decimals') > 3) { showMicrosec = true; @@ -881,8 +881,8 @@ function addDateTimePicker() { PMA_addDatepicker($(this), { showMillisec: showMillisec, showMicrosec: showMicrosec, - timeFormat: timeFormat, - }); + timeFormat: timeFormat, + }); }) } } @@ -3843,17 +3843,19 @@ AJAX.registerOnload('functions.js', function () { * Attach Ajax event handlers for input fields in the editor * and used to submit the Ajax request when the ENTER key is pressed. */ - $('#createViewDialog').find('input, select').live('keydown', function (e) { - if (e.which === 13) { // 13 is the ENTER key - e.preventDefault(); + if ($('#createViewDialog').length !== 0) { + $('#createViewDialog').find('input, select').live('keydown', function (e) { + if (e.which === 13) { // 13 is the ENTER key + e.preventDefault(); - // with preventing default, selection by tag + // was also prevented in IE + $(this).blur(); - $(this).closest('.ui-dialog').find('.ui-button:first').click(); - } - }); // end $.live() + $(this).closest('.ui-dialog').find('.ui-button:first').click(); + } + }); // end $.live() + } var $elm = $('textarea[name="view[as]"]'); if ($elm.length > 0) { diff --git a/js/rte.js b/js/rte.js index c42bd97ef3..8313d0b324 100644 --- a/js/rte.js +++ b/js/rte.js @@ -751,8 +751,6 @@ RTE.ROUTINE = { /** * Attach Ajax event handlers for the Routines, Triggers and Events editor - * - * FIXME: submit on ENTER keypress in dialog */ $(function () { /**