javascript event does not fire.
app/assets/javascripts/users.js
$(function(){
$("#user-search-field").on("keyup", function() {
console.log("OK");
});
});
I changed the file name of js.
app/assets/javascripts/test.js
$(function(){
$("#user-search-field").on("keyup", function() {
console.log("OK");
});
});
The event ignited.
I tried different file names.
○ test.js ○ ttt.js ○ user.js × users.js × groups.js ○ group.js
Only the same file name as the controller is useless.
When I looked closely, I noticed that there was the following file.
app/assets/javascripts/... groups.coffee users.coffee
Suspecting the influence of coffeescript, deleting the coffee file now fires an event.
Error when restarting rails again.
LoadError: cannot load such file -- coffee_script
uninstall coffee-rails
Gemfile
# gem 'coffee-rails', '~> 4.2'
terminal
bundle install
terminal
rails tmp:cache:clear
Solution!
https://qiita.com/yakimeron/items/7945a1350bd4b8c2438b
Recommended Posts