I'm using this snippet to show a spinner once a link is clicked. Some times the link .ln-edit-task
is loaded via Ajax, and the snippet breaks. How do I make it work on Ajax loaded content?
jQuery(document).on("ready page:change", function() {
return $(".ln-destroy-task").on("confirm:complete", function(e, response) {
if (response) {
return showSpinner($(this));
}
});
});
showSpinner = function(el) {
return el.find(".fa").removeClass().addClass("fa fa-spinner fa-spin");
};
Note that page:change
is required by Turbolinks in Rails.