Here's one tip on how to use it with rails (and simple_form) — or rather how to workaround the following issue.
When you write something like
$("#post_tag_list").autoSuggest(...);
for the first time, you'll expect AS to do all the wow stuff on the client side and have the original input field with the values as a parameter back on the server side, right?Well, I did.
Unfortunately, you have to work harder: not only you must include the
asHtmlID: "tag_list"
option in the autoSuggest
parameters, but (since that option actually defines the id's suffix only) you'll have to patch your controller allong the lines of:before_filter :autosuggest_fix
and
def autosuggest_fix
params[:post][:tag_list] = params[:as_values_tag_list] if params[:post]
end
If someone is reading this, there's now a new maintained fork of the plugin that has a useOriginalInputName option to help in this exact situation : https://github.com/hlsolutions/jquery-autosuggest
ReplyDelete