Opened 13 years ago

Closed 13 years ago

Last modified 11 years ago

#5826 closed bug (notabug)

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)

});

}

Change History (3)

comment:1 in reply to:  description Changed 13 years ago by pankajbhageria

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)

});

}

comment:2 Changed 13 years ago by Scott González

Resolution: invalid
Status: newclosed

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

comment:3 Changed 11 years ago by Scott González

Milestone: TBD

Milestone TBD deleted

Note: See TracTickets for help on using tickets.