From: Sven Schöling Date: Fri, 12 Jul 2013 13:33:50 +0000 (+0200) Subject: PartPicker: nicht global cachen sondern mit $.data ans DOM objekt packen X-Git-Tag: release-3.1.0beta1~173 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=670f111189bc790dbcf92f35798b570da39225cd;p=kivitendo-erp.git PartPicker: nicht global cachen sondern mit $.data ans DOM objekt packen --- diff --git a/js/autocomplete_part.js b/js/autocomplete_part.js index b9ef3e924..339801bb1 100644 --- a/js/autocomplete_part.js +++ b/js/autocomplete_part.js @@ -1,6 +1,9 @@ namespace('kivi', function(k){ - k.PartPickerCache = { } k.PartPicker = function($real, options) { + // short circuit in case someone double inits us + if ($real.data("part_picker")) + return $real.data("part_picker"); + var o = $.extend({ limit: 20, delay: 50, @@ -151,7 +154,7 @@ namespace('kivi', function(k){ pcont.append(picker); picker.addClass('icon16 CRM--Schnellsuche').click(open_dialog); - return { + var pp = { real: function() { return $real }, dummy: function() { return $dummy }, type: function() { return $type }, @@ -180,11 +183,13 @@ namespace('kivi', function(k){ }); } } + $real.data('part_picker', pp); + return pp; } }); $(function(){ $('input.part_autocomplete').each(function(i,real){ - kivi.PartPickerCache[real.id] = new kivi.PartPicker($(real)); + kivi.PartPicker($(real)); }) }); diff --git a/templates/webpages/part/_part_picker_result.html b/templates/webpages/part/_part_picker_result.html index 0512b49ad..6b848f3b4 100644 --- a/templates/webpages/part/_part_picker_result.html +++ b/templates/webpages/part/_part_picker_result.html @@ -26,6 +26,5 @@ [% L.paginate_controls(target='#part_picker_result', selector='#part_picker_result') %] diff --git a/templates/webpages/part/part_picker_search.html b/templates/webpages/part/part_picker_search.html index 69dca1b11..a3cf40618 100644 --- a/templates/webpages/part/part_picker_search.html +++ b/templates/webpages/part/part_picker_search.html @@ -15,7 +15,7 @@