I have a form_tag <%= form_tag(recommend_path, :method => "get", :id => "form") do %>
which works fine and redirects to the next page (recommend_path). The Recommend controller (page to be loaded after form submission (non-Ajax) has some very long analysis action (takes ~10s) before the next page loads.
What I am trying to achieve is to add an overlay with a loader while the Controller action is being done. I've added the overlay with a loader with success but it lasts only until form submit completion. To put it simply, after clicking the submit button, the overlay with a loader gets activated as desired but disappears after form submit completion (which takes only 1-2s) and the form page stays still for several seconds (while controller action being done) before moving to the next page.
I would like to catch that controller action completion with JavaScript(JQuery) or anything else so that the overlay with a loader stays until the next page loads.
Note: I am using TurboLinks.
Set in form html params like this:
html: {remote: true, id: 'form'}
And caught it with Javascript :
$('#form').on('ajax:complete', function(e, response){
# todo
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.