#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 Changed 13 years ago by
comment:2 Changed 13 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
This isn't a multi-demo; there is no extractLast function.
correction to the url in the solution: