From 75d1ad6ae3464410c2831de22302a713b1393e38 Mon Sep 17 00:00:00 2001 From: Stephen McMahon Date: Mon, 6 Jul 2015 14:44:58 +1000 Subject: [PATCH] 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 = $("