: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
- Marble Paint
(Friday 02/4/2011 – 1 Comment) - More Flickr Original Updates
(Sunday 01/23/2011 – 13 Comments) - Flickr Original updates
(Saturday 08/7/2010 – 19 Comments) - LED Light for iPhone 4
(Monday 06/28/2010 – 65 Comments)
