From 5cec90adf75c31ded8818f1348341563133daec7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 3 Jul 2013 19:24:20 +0200 Subject: [PATCH] caching der Widget und javascriptteile nach js/ verschoben --- js/autocomplete_part.js | 28 +++++++++++++++++-- .../webpages/part/_part_picker_result.html | 14 ++++------ .../webpages/part/part_picker_search.html | 19 ++----------- 3 files changed, 34 insertions(+), 27 deletions(-) diff --git a/js/autocomplete_part.js b/js/autocomplete_part.js index 6be8bb18a..66123e8af 100644 --- a/js/autocomplete_part.js +++ b/js/autocomplete_part.js @@ -1,5 +1,6 @@ namespace('kivi', function(k){ - k.part_picker = function($real, options) { + k.PartPickerCache = { } + k.PartPicker = function($real, options) { var o = $.extend({ limit: 20, delay: 50, @@ -64,6 +65,19 @@ namespace('kivi', function(k){ set_item({ id: last_real, name: last_dummy }) } + function update_results () { + $.ajax({ + url: 'controller.pl?action=Part/part_picker_result', + data: { + 'filter.all:substr::ilike': function(){ var val = $('#part_picker_filter').val(); return val === undefined ? '' : val }, + 'filter.type': $type.val(), + 'column': $column.val(), + 'real_id': $real.val, + }, + success: function(data){ $('#part_picker_result').html(data) } + }); + }; + $dummy.autocomplete({ source: function(req, rsp) { $.ajax($.extend(o, { @@ -129,11 +143,21 @@ namespace('kivi', function(k){ $dummy.after(pcont); pcont.append(picker); picker.addClass('icon16 CRM--Schnellsuche').click(open_dialog); + + return { + real: function() { return $real }, + dummy: function() { return $dummy }, + type: function() { return $type }, + column: function() { return $column }, + update_results: update_results, + set_item: set_item, + reset: make_defined_state, + } } }); $(function(){ $('input.part_autocomplete').each(function(i,real){ - kivi.part_picker($(real)); + kivi.PartPickerCache[real.id] = new kivi.PartPicker($(real)); }) }); diff --git a/templates/webpages/part/_part_picker_result.html b/templates/webpages/part/_part_picker_result.html index cae8d17f8..c6a814335 100644 --- a/templates/webpages/part/_part_picker_result.html +++ b/templates/webpages/part/_part_picker_result.html @@ -26,18 +26,14 @@ [% L.paginate_controls(target='#part_picker_result', selector='#part_picker_result') %] -- 2.20.1