rails link_to with remote => true and jquery on click
ruby-on-rails
Solution
Good question!!
I'm not sure about overriding the `click` event (I'm sure it will be fine to bind twice, but I've not got any references)
--
Ajax
In regards to calling a `preloader`, you'll want to use one of the `ajax` hooks that Rails UJS provides:
#app/assets/javascripts/application.js
$(".button_click").on("ajax:beforeSend", function(){
// preloader load
}).on("ajax:complete", function(){
//preloader hide
});
This will be what you need
Problem
I have simple question. I use rails link_to like this: ``` link_to 'sometxt', some_path(item), :class=>'fancybox button-click', :remote => true ``` and my question - is it right, to put jQuery on click event for this link ? ``` $('.button-click').on('click',function(){ //some action }); ``` or it isn't good solution to have link_to with remote and jQuery on click event for one link? What I want is to append loading gif when user click on link and fancybox showLoading doesn't work good for me so I'm trying other way to put preloader.