From: Thomas Gries Date: Mon, 13 Jun 2011 09:38:06 +0000 (+0000) Subject: fix for bug29368 which may have consequences. Please code reviewers, pls. check for... X-Git-Tag: 1.31.0-rc.0~29561 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=41a1fdb4d1c88e490c9d92eda8b0cfd79db347fc;p=lhc%2Fweb%2Fwiklou.git fix for bug29368 which may have consequences. Please code reviewers, pls. check for potential side effects - I cannot detect any, currently. --- diff --git a/resources/jquery/jquery.suggestions.js b/resources/jquery/jquery.suggestions.js index 64e06d90db..828e96d099 100644 --- a/resources/jquery/jquery.suggestions.js +++ b/resources/jquery/jquery.suggestions.js @@ -66,20 +66,26 @@ $.suggestions = { }, /** * Ask the user-specified callback for new suggestions. Any previous delayed call to this function still pending - * will be canceled. If the value in the textbox hasn't changed since the last time suggestions were fetched, this + * will be canceled. If the value in the textbox is or hasn't changed since the last time suggestions were fetched, this * function does nothing. * @param {Boolean} delayed Whether or not to delay this by the currently configured amount of time */ update: function( context, delayed ) { - // Only fetch if the value in the textbox changed + // Only fetch if the value in the textbox changed and is not empty function maybeFetch() { - if ( context.data.$textbox.val() !== context.data.prevText ) { + if ( ( context.data.$textbox.val().length != 0 ) && ( context.data.$textbox.val() !== context.data.prevText ) ) { context.data.prevText = context.data.$textbox.val(); 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 text 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 );