Jquery AutoComplete firefox 中文 Ajax (option url or data) Jquery rails 自动完成
application.html
http://docs.jquery.com/Plugins/autocomplete
<!DOCTYPE html><html><head> <title>AotoComplete</title> <%= stylesheet_link_tag :all %> <%= javascript_include_tag 'AutoComplete/jquery','AutoComplete/jquery.autocomplete','AutoComplete/jquery.bgiframe.min' %> <%= stylesheet_link_tag 'AutoComplete/jquery.autocomplete','AutoComplete/main' %> <%= csrf_meta_tag %></head><body><%= yield %></body></html>
<script> $(document).ready(function(){ $("#product_name").autocomplete('/products/search',{matchContains: false})}</script>
....def search key_word = params[:q] # Product.limit(params[:limit]) @product_names = Product.connection.select_values("select name from products where name like '%#{key_word}%'") respond_to do |format| format.html { render :text => @product_names.join("\n")} end end...
resources :products do collection do get 'search' end end
.bind("unautocomplete", function() {select.unbind();$input.unbind();$(input.form).unbind(".autocomplete"); # 下面添加}).bind("input", function() { // @hack by liqt:support for inputing chinese characters in firefox onChange(0, true);