Skip to main content

Search and Top Navigation

#5826 closed bug (notabug)

Opened July 14, 2010 07:08PM UTC

Closed July 14, 2010 07:14PM UTC

Last modified October 11, 2012 09:15PM UTC

Autocomplete#remote-with-cache example doesnot work after the first word. (Solution is there)

Reported by: pankajbhageria Owned by:
Priority: critical Milestone:
Component: ui.core Version: 1.8.2
Keywords: Cc:
Blocked by: Blocking:
Description

http://jqueryui.com/demos/autocomplete/#remote-with-cache

current code with bug:

source: function(request, response) {

if ( request.term in cache ) {

response( cache[ request.term ] );

return;

}

$.ajax({

url: "search.php",

dataType: "json",

data: request,

success: function( data ) {

cache[ request.term ] = data;

response( data );

}

});

}

The problem with the above is that the request.term is a string of all the values entered till now. It needs to be processed to extract the last term from it.

correct code:

source: function(request, response) {

var term = extractLast(request.term);

if (term in cache ) {

response( cache[term] );

return;

}

$.getJSON("/allergies", {

term: term

}, function(data){

cache[ request.term ] = data;

response(data)

});

}

Attachments (0)
Change History (3)

Changed July 14, 2010 07:10PM UTC by pankajbhageria comment:1

correction to the url in the solution:

source: function(request, response) {

var term = extractLast(request.term);

if (term in cache ) {

response( cache[term] ); return;

}

$.getJSON("search.php", {

term: term

}, function(data){

cache[ request.term ] = data; response(data)

});

}

Changed July 14, 2010 07:14PM UTC by scottgonzalez comment:2

resolution: → invalid
status: newclosed

This isn't a multi-demo; there is no extractLast function.

Changed October 11, 2012 09:15PM UTC by scottgonzalez comment:3

milestone: TBD

Milestone TBD deleted