From 670f111189bc790dbcf92f35798b570da39225cd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 12 Jul 2013 15:33:50 +0200 Subject: [PATCH] PartPicker: nicht global cachen sondern mit $.data ans DOM objekt packen --- js/autocomplete_part.js | 11 ++++++++--- templates/webpages/part/_part_picker_result.html | 3 +-- templates/webpages/part/part_picker_search.html | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) 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 @@