Ive been at this for hours and i am still unable to get jquery autocomplete to work even after following the examples on here and the examples on github. What are the exact files i am suppose to use because i set everything up, routes are correct, seed and still get no jquery autocomplete, the textbox not doing anything.
Here are the files i am using right now:
autocomplete-rails.js
jquery.js
jquery.min.js
jquery_ujs.js
jquery-ui.js
jquery-ui.min.js
Something doesn't look right, has anyone done this before, what files do you have?
EDIT, UPDATED AND WORKING:
Make sure you have the correct files AND put the images inside of the public/images folder.
jqu开发者_Python百科ery.js
jquery_ujs.js
jquery-ui.js
rails.js
autocomplete-rails.js
application.js
and then have my custom theme:
jquery-ui-1.8.13.custom.css
Rails3 project with jquery need below, and you can check out in config/application.rb
jquery.js
rails.js
And using autocomplete, you need:
jquery-ui.min.js
Here's a snipit of jquery code that's working for me:
$.getJSON("/polymerases.json",function(polsFromServer){
pols = polsFromServer;
$(#polymerases).autocomplete({
source: pols
});
});
here's my controller code:
@polymerases = Polymerase.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @polymerases }
format.json do
response.headers["Cache-Control"] = "public, max-age=60"
render :json => @polymerases.map(&:formatted_name).to_json
end
end
I'm including 'jquery-1.5.2.min.js', 'jquery-ui-1.8.13.custom.min.js' as well as my local js file (see above) that does the .autocomplete call to bind up the autocomplete functionality to the selected input box.
I think you don't need the non minified versions of jquery and jquery-ui. I'm not familiar with the _ujs or autocomlete-rails bits.
If you're not using firebug or chrome's developer mode to step through your javascript, I strongly recommend you do that.
Also, it might help to look at your raw json data (eg: http://localhost:3000/polymerases.json)
精彩评论