From 5aa1a72160547cc2abd77bb414e3c7b69cf2ec87 Mon Sep 17 00:00:00 2001 From: Stephen McMahon Date: Mon, 23 Feb 2015 13:59:38 +1100 Subject: [PATCH 1/2] Set first input of modal form to be focused on dialog open --- javascript/quickaddnew.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/javascript/quickaddnew.js b/javascript/quickaddnew.js index ab8522f..5662b71 100644 --- a/javascript/quickaddnew.js +++ b/javascript/quickaddnew.js @@ -92,6 +92,8 @@ jQuery.entwine("quickaddnew", function($) { dlg.load(this.getURL(), function(){ dlg.parent().removeClass("loading"); + // set focus to first input element + dlg.find('form :input:visible:enabled:first').focus(); }); } }); From 75d1ad6ae3464410c2831de22302a713b1393e38 Mon Sep 17 00:00:00 2001 From: Stephen McMahon Date: Mon, 6 Jul 2015 14:44:58 +1000 Subject: [PATCH 2/2] Fix quickaddnew sometimes getting entwined twice Issue stems from jQuery plugins like Select2 re-writing the dom and causing entwine to match quickaddnew to the field a second time. This then causes issues with doubled up buttons and dialogs. The other potential fix is making sure quickaddnew fires last in the page build but this can't be guaranteed. --- javascript/quickaddnew.js | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/javascript/quickaddnew.js b/javascript/quickaddnew.js index 5662b71..8b361bf 100644 --- a/javascript/quickaddnew.js +++ b/javascript/quickaddnew.js @@ -18,7 +18,12 @@ jQuery.entwine("quickaddnew", function($) { URL: null, onmatch: function() { var self = this; - + + //Check to see if quickaddnew has been bound to this field before, sometimes jQuery plugins like Select2 + //will trigger a binding a second time that we don't want. + if($(this).parents().children('.quickaddnew-button').length > 0) { + return; + } // create add new button var button = $("