From 2c739dfda3d2f83c3a66d5661d1c63f475cbaab3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Mon, 15 Jul 2013 16:08:09 +0200 Subject: [PATCH] make_defined_state auch beim Klicken ausserhalb des Pickers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Problem war, dass ein einfacher blur handler auch getriggert hat wenn das jqm aufgeht. Dafür ist der timermechanismus jetzt mit ins widget gewandert und der blur handler wird einfach abgebrochen --- js/autocomplete_part.js | 18 +++++++++++++++--- .../webpages/part/part_picker_search.html | 6 +----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/js/autocomplete_part.js b/js/autocomplete_part.js index 0a4886f17..b89751e3b 100644 --- a/js/autocomplete_part.js +++ b/js/autocomplete_part.js @@ -26,7 +26,9 @@ namespace('kivi', function(k){ var state = STATES.PICKED; var last_real = $real.val(); var last_dummy = $dummy.val(); - var open_dialog = function(){ + var timer; + + function open_dialog () { open_jqm_window({ url: 'controller.pl?action=Part/part_picker_search', data: $.extend({ @@ -34,8 +36,9 @@ namespace('kivi', function(k){ }, ajax_data($dummy.val())), id: 'part_selection', }); + window.clearTimeout(timer); return true; - }; + } function ajax_data(term) { var data = { @@ -89,6 +92,11 @@ namespace('kivi', function(k){ }); }; + function result_timer (event) { + window.clearTimeout(timer); + timer = window.setTimeout(update_results, 100); + } + function close_popup() { $('#part_selection').jqmClose() }; @@ -156,7 +164,10 @@ namespace('kivi', function(k){ } }); -// $dummy.blur(make_defined_state); // blur triggers also on open_jqm_dialog + $dummy.blur(function(){ + window.clearTimeout(timer); + timer = window.setTimeout(make_defined_state, 100); + }); // now add a picker div after the original input var pcont = $('').addClass('position-absolute'); @@ -173,6 +184,7 @@ namespace('kivi', function(k){ convertible_unit: function() { return $convertible_unit }, column: function() { return $column }, update_results: update_results, + result_timer: result_timer, set_item: set_item, reset: make_defined_state, init_results: function () { diff --git a/templates/webpages/part/part_picker_search.html b/templates/webpages/part/part_picker_search.html index a3cf40618..318c95e10 100644 --- a/templates/webpages/part/part_picker_search.html +++ b/templates/webpages/part/part_picker_search.html @@ -14,14 +14,10 @@ -- 2.20.1