When I used to write Perl CGI scripts I displayed an animated gif image whilst waiting for a long database query to load, and some javascript to remove the image once the content was available. I''d like to do the same thing with Rails, but it''s not clear to me how to do this in Rails. Does anyone have any suggestions? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Milo Thurston wrote:> When I used to write Perl CGI scripts I displayed an animated gif image > whilst waiting for a long database query to load, and some javascript to > remove the image once the content was available. > I''d like to do the same thing with Rails, but it''s not clear to me how > to do this in Rails. Does anyone have any suggestions?in rails-ajax you have a :loading => "Jsfunct()", :complete => "Jsfunct2()" for all of the prototype based js-rails things. you can do something like (given you have the :defaults js files included in the <head> ) DOM -------------------------------------------------------------- <div> <div id="spinner" style="display:none;"><img src="loading.gif"></div> <div id="dom_updater">The ajax call will replace this div</div> </div> link_to_remote "load query", :url => {:controller=>''mycontroller'', :action=>''queryloader''}, :update => "dom_updater", :loading => "Element.show(''spinner'')", :complete => "Element.hide(''spinner'')" class cController def queryloader BigModel.find(:all) # make long query render_text "this will be replaced in the div called dom_updater!" end end -------------------------------------------------------------- ..the img is actually placed on the page at start but with display:none. when the ajax call is made, the :loading opt loads a js function (it could be any function u define, i chose the simple prototype Element.show/hide) that displays / hides the img according to the process of the action in the background. hope it helps! s -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Shai Rosenfeld wrote:> ..the img is actually placed on the page at start but with display:none. > when the ajax call is made, the :loading opt loads a js function (it > could be any function u define, i chose the simple prototype > Element.show/hide) that displays / hides the img according to the > process of the action in the background.That looks a lot better than my crude Perl methods! I will give it a go, but I''m not sure whether it will work with my odd setup (can''t test right now, whilst I populate the database). The search button submits a form, calling the search method. If there is anything found by the search then it stores the results in the session and re-directs to a "view results" page. So, the "search" page is never actually rendered. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---