Reputation: 2653
Rails 3 offer application.html.erb
as a layout template. However, whenever you send request to access a controller view, the content of application.html.erb
will be loaded again. This seems not efficient, since header, navigation, footer only need to be loaded once.
In addition, when you need to have a javascript code executed in $(window).load
for application.html.erb
and another js method executed in $(window).load
for <controller>.html.erb
, this will mess up. I think the reason is that $(window).load
can only execute once for each page.
So I wonder what's the best Layout practice for Rails 3.
Thanks
Upvotes: 1
Views: 276
Reputation: 29880
Rails 4 includes Turbolinks, which will only reload the body of your website when a link is clicked, instead of reloading all of the assets like javascript and CSS. If you want to fine tune what gets loaded further, you can take a look at pjax, but I think for most applications Turbolinks will be sufficient.
Upvotes: 1