From: Thomas Gries Date: Mon, 13 Jun 2011 11:16:31 +0000 (+0000) Subject: follow up patch to r89950 r89952 r89953 r89955 : moved div clearing inside call back... X-Git-Tag: 1.31.0-rc.0~29557 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=cda391eb7b8e1c4dba254a3180d28b095097a4ba;p=lhc%2Fweb%2Fwiklou.git follow up patch to r89950 r89952 r89953 r89955 : moved div clearing inside call back function maybeFetch so that this is also done when coming from timeouts --- diff --git a/resources/jquery/jquery.suggestions.js b/resources/jquery/jquery.suggestions.js index 4c23b19616..12f265606c 100644 --- a/resources/jquery/jquery.suggestions.js +++ b/resources/jquery/jquery.suggestions.js @@ -72,20 +72,18 @@ $.suggestions = { */ update: function( context, delayed ) { // Only fetch if the value in the textbox changed and is not empty + // if the textbox is empty then clear the result div, but leave other settings intouched function maybeFetch() { - if ( ( context.data.$textbox.val().length != 0 ) && ( context.data.$textbox.val() !== context.data.prevText ) ) { - context.data.prevText = context.data.$textbox.val(); + if ( context.data.$textbox.val().length == 0 ) { + context.data.$container.hide(); + context.data.prevText = ''; + } else if ( context.data.$textbox.val() !== context.data.prevText ) { if ( typeof context.config.fetch == 'function' ) { context.config.fetch.call( context.data.$textbox, context.data.$textbox.val() ); } } } - // clear result div if the value in the textbox is empty - if ( context.data.$textbox.val().length == 0 ) { - context.data.$container.hide(); - } - // Cancel previous call if ( context.data.timerID != null ) { clearTimeout( context.data.timerID );