I have a link with remote: true
attribute. It goes to the function then the js.erb file. My question is how can I add loading icon rails way?
For instance, if I put ajax request it is easy;
$.ajax({
type: 'POST',
url: form.attr('action'),
data: form.serialize(),
dataType: 'json',
beforeSend: function() {//add icon here}
success: function(data){
},
error: function() {
}
});
But when I work with remote: true with link or button where should I put the loading icon.
PS: I do not want to add smth like below to the dom.
$('#mybutton').on('click', function(){$('#div-to-loading').prepend('.loading-icon')})
EDIT
Please read my question carefully. I know how to add loading icon with ajax call. I am asking how to do it with rails way. I have a link with remore:true
option. It goes to controller action then rendering js file myfunc.js.erb
.
Where should I put loading icon?