I am using the jQuery autocomplete plugin for a smart input box. I want the first parameter in the input box to be autocompleted from one dataset, then once that has been selected change the dataset for the second parameter.
So if I have the following:
var foo = ['a','b','c'];
var bar = ['x','y','z'];
$("#input_box").autocomplete(
foo, { multiple: true, multipleSeparator: " "}
);
I want to be able to dynamically change the 'foo' dataset to 'bar' after the first parameter has been autocompleted.
Any ideas how to do this?
Try:
var fubar = foo;
$("#input_box").autocomplete(
fubar, { multiple: true, multipleSeparator: " "}
).live('keyup', function() {
if($(this).val().length > 1)
fubar = bar;
else fubar = foo;
});
//EDITED, forgot .length which is key :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.