greghauptmann
2010-Feb-24 11:37 UTC
[Rails] javascript question - why does “window.location” not ensure my spinner.gif animation works?
Hi, It seems when I use "window.location" as a means to redirect to the API when my longer running transaction is does not ensure the animation for the spinner gif I have works. Any ideas how to fix this? ie. I see the gif ok but it not being animated. Is there another way in Javascript to force the redirect once the gif animation starts? What''s the easiest way in Rails to get a "spinner" being show for the initial spash page whilst it goes to the database to prepare the detail for the main page. <div id="loading"> </div> <script type="text/javascript" charset="utf-8"> function show_spinner() { $("form").hide() $("loading").show() window.location = "/weekends/display" # <== SEEMS TO STOP SPINNER ANIMATION } window.onload=show_spinner; </script> CSS: #loading { width:100px; height: 100px; position: fixed; top: 50%; left: 50%; background:url(/images/ajax-loader.gif) no-repeat center #fff; text-align:center; padding:10px; font:normal 16px Tahoma, Geneva, sans-serif; # border:1px solid #666; margin-left: -50px; margin-top: -50px; z-index:2; overflow: auto; } -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
ayupmeduck
2010-Feb-25 06:22 UTC
[Rails] Re: javascript question - why does “window.location” not ensure my spinner.gif animation works?
In general I''ve found that only Internet Explorer (6, 7 & 8) has this problem, whereas other browsers such as Firefox and Safari are ok. In your case is the problem only with IE? On Feb 24, 12:37 pm, greghauptmann <greg.hauptm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > It seems when I use "window.location" as a means to redirect to the > API when my longer running transaction is does not ensure the > animation for the spinner gif I have works. Any ideas how to fix this? > ie. I see the gif ok but it not being animated. Is there another way > in Javascript to force the redirect once the gif animation starts? > What''s the easiest way in Rails to get a "spinner" being show for the > initial spash page whilst it goes to the database to prepare the > detail for the main page. > > <div id="loading"> > </div> > > <script type="text/javascript" charset="utf-8"> > function show_spinner() { > $("form").hide() > $("loading").show() > window.location = "/weekends/display" # <== SEEMS TO STOP > SPINNER ANIMATION > } > window.onload=show_spinner; > </script> > > CSS: > > #loading { > width:100px; > height: 100px; > position: fixed; > top: 50%; > left: 50%; > background:url(/images/ajax-loader.gif) no-repeat center #fff; > text-align:center; > padding:10px; > font:normal 16px Tahoma, Geneva, sans-serif; > # border:1px solid #666; > margin-left: -50px; > margin-top: -50px; > z-index:2; > overflow: auto; > > }-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
greghauptmann
2010-Feb-25 06:25 UTC
[Rails] Re: javascript question - why does “window.location” not ensure my spinner.gif animation works?
actually - I''ve had some advice towards a better option - now I''m using jQuery and doing: $(''body'').ajaxStart(function(){ $(''#spinner'').show(); }); $(''body'').ajaxStop(function(){ $(''#spinner'').hide(); }); On Feb 25, 4:22 pm, ayupmeduck <brod.just...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> In general I''ve found that only Internet Explorer (6, 7 & 8) has this > problem, whereas > other browsers such as Firefox and Safari are ok. In your case is the > problem > only with IE? > > On Feb 24, 12:37 pm, greghauptmann <greg.hauptm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > It seems when I use "window.location" as a means to redirect to the > > API when my longer running transaction is does not ensure the > > animation for the spinner gif I have works. Any ideas how to fix this? > > ie. I see the gif ok but it not being animated. Is there another way > > in Javascript to force the redirect once the gif animation starts? > > What''s the easiest way in Rails to get a "spinner" being show for the > > initial spash page whilst it goes to the database to prepare the > > detail for the main page. > > > <div id="loading"> > > </div> > > > <script type="text/javascript" charset="utf-8"> > > function show_spinner() { > > $("form").hide() > > $("loading").show() > > window.location = "/weekends/display" # <== SEEMS TO STOP > > SPINNER ANIMATION > > } > > window.onload=show_spinner; > > </script> > > > CSS: > > > #loading { > > width:100px; > > height: 100px; > > position: fixed; > > top: 50%; > > left: 50%; > > background:url(/images/ajax-loader.gif) no-repeat center #fff; > > text-align:center; > > padding:10px; > > font:normal 16px Tahoma, Geneva, sans-serif; > > # border:1px solid #666; > > margin-left: -50px; > > margin-top: -50px; > > z-index:2; > > overflow: auto; > > > }-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.