* @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 and is not empty
+ // Only fetch if the value in the textbox changed and is not empty, or if the results were hidden
// 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.$container.hide();
context.data.prevText = '';
- } else if ( context.data.$textbox.val() !== context.data.prevText ) {
+ } else if (
+ context.data.$textbox.val() !== context.data.prevText ||
+ !context.data.$container.is( ':visible' )
+ ) {
if ( typeof context.config.fetch === 'function' ) {
context.data.prevText = context.data.$textbox.val();
context.config.fetch.call( context.data.$textbox, context.data.$textbox.val() );
var selected = context.data.$container.find( '.suggestions-result-current' );
if ( !result.get || selected.get( 0 ) !== result.get( 0 ) ) {
if ( result === 'prev' ) {
- if( selected.is( '.suggestions-special' ) ) {
+ if( selected.hasClass( 'suggestions-special' ) ) {
result = context.data.$container.find( '.suggestions-result:last' );
} else {
result = selected.prev();
- if ( !( result.length && result.hasClass( '.suggestions-result' ) ) ) {
+ if ( !( result.length && result.hasClass( 'suggestions-result' ) ) ) {
// there is something in the DOM between selected element and the wrapper, bypass it
result = selected.parents( '.suggestions-results > *' ).prev().find( '.suggestions-result' ).eq(0);
}
}
} else {
result = selected.next();
- if ( !( result.length && result.hasClass( '.suggestions-result' ) ) ) {
+ if ( !( result.length && result.hasClass( 'suggestions-result' ) ) ) {
// there is something in the DOM between selected element and the wrapper, bypass it
result = selected.parents( '.suggestions-results > *' ).next().find( '.suggestions-result' ).eq(0);
}
- if ( selected.is( '.suggestions-special' ) ) {
+ if ( selected.hasClass( 'suggestions-special' ) ) {
result = $( [] );
} else if (
result.length === 0 &&