How to show an animated spinner while a background task is processing in nested rails model using aj
- by Globalkeith
My specific example is highly complex, so I will use the example shown by Ryan from Railscasts to discuss this:
http://railscasts.com/episodes/197-nested-model-form-part-2
Background
I have a form, let's say "Survey", which contains an arbitrary number of "Questions".
Senario
Give i am on the "Edit Survey" page.
I would like to add a button to each "Question" field which calls a remote_function, which in turn queue's up a delayed_job to execute some processing on the "Question".
To give feedback to the user, i would like to disable the button, and show an animated spinner, which remains until the delayed_job has processed the "Question".
Hint - I can add methods to the "Question" model to indicate the status of the delayed_job.
So, with best practices in mind, what is the best way to achieve this?