From 0ca8b7f05409b6d8a5441fa4337aa466ba77aa20 Mon Sep 17 00:00:00 2001 From: David Morton Date: Sun, 17 Jul 2011 12:56:32 -0500 Subject: [PATCH 1/3] Added config option "ontab" which allows for the default tab action to be overridden, to either escape or submit the form. Also allow the enter key to submit the form if no submit button is present, on a select input. --- jquery.jeditable.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/jquery.jeditable.js b/jquery.jeditable.js index eb8a911..bb672e7 100644 --- a/jquery.jeditable.js +++ b/jquery.jeditable.js @@ -48,6 +48,7 @@ * @param String options[select] true or false, when true text is highlighted ?? * @param String options[placeholder] Placeholder text or html to insert when element is empty. ** * @param String options[onblur] 'cancel', 'submit', 'ignore' or function ?? + * @param String options[ontab] 'submit', or 'escape', block default browser tab action and take our own action * * @param Function options[onsubmit] function(settings, original) { ... } called before submit * @param Function options[onreset] function(settings, original) { ... } called before reset @@ -261,6 +262,15 @@ e.preventDefault(); reset.apply(form, [settings, self]); } + if (e.keyCode === 9) { + if (settings.ontab === "escape") { + e.preventDefault(); + reset.apply(form, [settings, self]); + } else if (settings.ontab === "submit"){ + e.preventDefault(); + form.submit(); + } + } }); /* Discard, submit or nothing with changes when clicking outside. */ @@ -515,6 +525,13 @@ $('select', this).change(function() { form.submit(); }); + /* also allow enter to submit, even if no change */ + $('select', this).keydown(function(e) { + if (e.keyCode == 13) { + e.preventDefault(); + form.submit(); + } + }); } } } From 39b77de04ea9663869e153e99f0fb7c1984a004a Mon Sep 17 00:00:00 2001 From: David Morton Date: Fri, 22 Jul 2011 10:26:33 -0500 Subject: [PATCH 2/3] I cannot duplicate problem with 7d8f7357 - this code works in IE. This gets rid of an extra loop. --- jquery.jeditable.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/jquery.jeditable.js b/jquery.jeditable.js index bb672e7..f248474 100644 --- a/jquery.jeditable.js +++ b/jquery.jeditable.js @@ -510,15 +510,13 @@ continue; } var option = $('