I can’t seem to have coffee script works. I am trying a simple auto complete with jquery.
Here the code i have that i am trying to implement an autocompletion on
<%= form_tag "/search", :method => "get" do %>
<%= text_field_tag :query, params[:query], :value => "Search for people.", :class=>"searchbox", :onclick=>"this.value='';", :id => "querysearch" %>
<%= image_submit_tag("site/blankimg.png", :name => nil, :class=>"searchbox_submit" ) %>
<% end %>
The auto completion has to be on the text field, and call the following coffeescript to run it
jQuery ->
$('#querysearch').autocomplete
source: ['foo', 'food', 'four']
Now when i run the server, nothing work however i do see if i check my source code on the link the following script
(function() {
jQuery(function() {
return $('#querysearch').autocomplete({
source: ['foo', 'food', 'four']
});
});
}).call(this);
Now i do not know if the coffeescript was executed, in my gem file i have the following
source 'https://rubygems.org'
gem 'rails', '3.2.6'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
gem 'devise'
gem "RedCloth", "~> 4.2.9"
gem "paperclip", "~> 3.0"
gem "paperclip-ffmpeg"
gem 'geocoder'
gem "coffee-script"
...
I also try the following comment from this posts Application.js.coffee rails but i am not sure if there is anything else wrong?
I’m not familiar with the library you’re using, but shouldn’t…
Be…
Your current implementation actually calls jQuery as a function instead of attaching a callback handler.