My rails app has two pages based on two controllers/ views/ models..both controllers use a different layout
Controller A/ View A – Uses layout A – uses jquery js/jquery css
Controller B/ View B – Uses layout B – without jquery…standard default..
When I navigate from a page A (based controller A/ View A) to page B ( based on controller B / View B) …the layout change does not take effect immediately. I have to manually ‘reload the page’ from the browser…for the layout to kick in.
Why does the layout change not become effective automatically ? What can I do to make that happen ?
When I switch back from page B to Page A…the layout changes immediately….not sure why the same thing does not happen when I move from page A to B.
Added code for layouts:
-- Layout 1
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</meta>
<title>myapp1</title>
<%= stylesheet_link_tag "jquery.mobile.min.css" %>
<%= javascript_include_tag "application","rails","jquery.min.js","jquery.mobile.min.js" %>
<%= csrf_meta_tag %>
</head>
<body>
<div data-role= "page" >
<%= yield %>
</div>
</body>
</html>
-- Layout 2
<!DOCTYPE html>
<html>
<head>
<title>myapp1</title>
<%= csrf_meta_tag %>
</head>
<body>
<div data-role= "page" >
<%= yield %>
</div>
</body>
</html>
Adding excerpts of controller code where layouts are called:
controller # 1
class HeadersController < ApplicationController
layout "xjquery"
before_filter :authenticate
controller # 2
class RhattachmentsController < ApplicationController
layout "xplain"
def index
rhid = session[:header_id]
What finally worked for me was adding
:rel=>"external"to the link_to which takes me from View A to ControllerB/View B. This forces a full page reload and also applies the new layout immediately.