I have use rails3-jquery-autocomplete plugin and I am just wondering how can I use it to do multiple words autocomplete.
e.g. INPUT rails, gem
it should generate auto-list twice.
How to solve this problem?..
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
rails3-jquery-autocomplete plugin? It seems that it doesn’t support multiple autocomplete, you need to modify the plugin code!!
If you insist on your former ideas, follow my steps.
bundle show rails3-jquery-autocompleteto get the plugin working directroymodify the
define_methodlike this:end
modify
autocomplete-rails.jslike thisfunction split(val) {
return val.split(/,\s*/);
}
function extractLast(term) {
return split(term).pop();
}
$(document).ready(function(){
$('input[autocomplete]').each(function(i){
$(this).autocomplete({
source: $(this).attr('autocomplete'),
focus: function() {
return false;
},
select: function(event, ui) {
var terms = split( this.value );
// remove the current input
terms.pop();
// add the selected item
terms.push( ui.item.value );
// add placeholder to get the comma-and-space at the end
terms.push("");
this.value = terms.join(",");
return false;
}
});
});
});
restart your server and try
!! remember you’d better backup autocomplete.rb to avoid overwrite after you run bundle install.
Good luck!