I am using some nested layouts in Ruby on Rails, and in one of the layouts i have a need to read in a string from a div and set that as the title of the document. What is correct way (if any) to set the title of the document?
<script type="text/javascript">
$(document).ready(function() {
// ???
});
</script>
The correct way to do this is on the server side.
In your layout, there at some point will be some code which puts the text in the div. Make this code also set some instance variable such as
@page_title
, and then in your outer layout have it do<%= @page_title || 'Default Title' %>