:layout => false
Thursday 11/27/2008 – Category: Merb
I ran into a strange behavior when trying to use setInterval in JS to make an AJAX request every n seconds. I had the timer in the $(document).ready(function() { } in the head of my application layout file.
There would be strange behavior with the timer--every interval would be twice as fast as the previous, and the browser would quickly become unresponsive and crash.
I initially thought it was a Firefox bug so I wasted sometime googling setInterval but it turns out the AJAX request was rendering the view with the layout, thus creating another timer on each request. Stupid.
Setting :layout => false on the offending action made everything play nice. Moral of the story: don't forget to exclude your layouts for AJAX actions.
Leave a Reply
Recent Posts
- LED Light for iPhone 4
(Monday 06/28/2010 – 38 Comments) - WWDC 2010: Worth Every Minute
(Monday 06/14/2010 – No Comments) - Flickr Original for Safari 5!
(Wednesday 06/9/2010 – 15 Comments) - iPad thoughts
(Friday 04/2/2010 – 1 Comment)
