Index: trunk/phase3/resources/jquery/jquery.suggestions.js |
— | — | @@ -72,20 +72,18 @@ |
73 | 73 | */ |
74 | 74 | update: function( context, delayed ) { |
75 | 75 | // Only fetch if the value in the textbox changed and is not empty |
| 76 | + // if the textbox is empty then clear the result div, but leave other settings intouched |
76 | 77 | function maybeFetch() { |
77 | | - if ( ( context.data.$textbox.val().length != 0 ) && ( context.data.$textbox.val() !== context.data.prevText ) ) { |
78 | | - context.data.prevText = context.data.$textbox.val(); |
| 78 | + if ( context.data.$textbox.val().length == 0 ) { |
| 79 | + context.data.$container.hide(); |
| 80 | + context.data.prevText = ''; |
| 81 | + } else if ( context.data.$textbox.val() !== context.data.prevText ) { |
79 | 82 | if ( typeof context.config.fetch == 'function' ) { |
80 | 83 | context.config.fetch.call( context.data.$textbox, context.data.$textbox.val() ); |
81 | 84 | } |
82 | 85 | } |
83 | 86 | } |
84 | 87 | |
85 | | - // clear result div if the value in the textbox is empty |
86 | | - if ( context.data.$textbox.val().length == 0 ) { |
87 | | - context.data.$container.hide(); |
88 | | - } |
89 | | - |
90 | 88 | // Cancel previous call |
91 | 89 | if ( context.data.timerID != null ) { |
92 | 90 | clearTimeout( context.data.timerID ); |