stewart715
stewart715

Reputation: 5647

rails running methods after view is loaded

I would like to show a spinning 'loading' image while my method computes some things and returns the results to the view.

Currently, it just looks as though the page isn't loading at all and then does (it's performing the method).

Any ideas?

Upvotes: 1

Views: 93

Answers (1)

Jeremy Roman
Jeremy Roman

Reputation: 16355

One approach would be for the page you're loading to simply be the loading indicator, and have it do an AJAX request to retrieve the rest of the results (you can use jQuery or something similar to issue the request and then insert the results into the document).

If you're feeling up to it, you could instead use the HTTP streaming support that's new in Rails 3.1.

http://railscasts.com/episodes/266-http-streaming

Upvotes: 3

Related Questions