Note that there are some explanatory texts on larger screens.

plurals
  1. POTwo content_for the same yield renders in all the views (Rails 3)
    primarykey
    data
    text
    <p>I have two separate views which are outputting content for a named yield block called :icons.</p> <p>When I load the two pages, I always see in the :icons block the content of the 2 views... :-(</p> <p>View 1 : Projects#Index</p> <pre><code>&lt;% content_for :icons do %&gt; Project Icons ... &lt;% end %&gt; ... </code></pre> <p>View 2 : Tree#Show</p> <pre><code>&lt;% content_for :icons do %&gt; &lt;a href="javascript:void(0)" id="dynatree-expand-all"&gt;Expand&lt;/a&gt; &lt;a href="javascript:void(0)" id="dynatree-collapse-all"&gt;Collapse&lt;/a&gt; &lt;a href="javascript:void(0)" id="dynatree-transfer"&gt;Import&lt;/a&gt; &lt;div id="viewname_selector"&gt; &lt;%= form_tag({:controller =&gt; :loopview, :action =&gt; :show}, { :id =&gt; "viewname_form" ,:remote =&gt; true}) do %&gt; &lt;%= collection_select(:viewname, :id, @viewnames, :id, :name, :selected =&gt; @current_viewname_id) %&gt; &lt;% end %&gt; &lt;/div&gt; &lt;% end %&gt; </code></pre> <p>And the call in the application.html.erb is</p> <pre><code>&lt;div id="icons"&gt; &lt;%= yield :icons %&gt; &lt;/div&gt; </code></pre> <p>When I load Projects#index, I have only the Project Icons (so it is ok).</p> <p>When I load Tree#index, I have the tree icons AND the project icons ...</p> <p>What Am I doing wrong ? How to get only the tree icons in the tree view ?</p> <p>Edit : Complete source of tree#index</p> <pre><code>&lt;% content_for :head do %&gt; &lt;title&gt;Dynatree View &lt;%= sicadea %&gt;&lt;/title&gt; &lt;%= javascript_include_tag "leanModal/jquery.leanModal.min" %&gt; &lt;%# For the dynatree %&gt; &lt;%= stylesheet_link_tag "dynatree/skin/ui.dynatree.css" %&gt; &lt;%= stylesheet_link_tag "dynatree/skin/ui.dynatree.custom.css" %&gt; &lt;%= javascript_include_tag "cookie/jquery.cookie.js" %&gt; &lt;%= javascript_include_tag "dynatree/jquery.dynatree-1.2.4.js" %&gt; &lt;%= stylesheet_link_tag "contextMenu/jquery.contextMenu.css" %&gt; &lt;%= javascript_include_tag "contextMenu/jquery.contextMenu-custom.js" %&gt; &lt;%= javascript_include_tag "contextMenu/jquery.ui.position.js" %&gt; &lt;%= javascript_include_tag "dynatree.js" %&gt; &lt;%# for the poin'ts table %&gt; &lt;%= stylesheet_link_tag "loopview.css" %&gt; &lt;% end %&gt; &lt;% content_for :icons do %&gt; &lt;a href="javascript:void(0)" id="dynatree-expand-all"&gt;Expand&lt;/a&gt; | &lt;a href="javascript:void(0)" id="dynatree-collapse-all"&gt;Collapse&lt;/a&gt; | &lt;a href="javascript:void(0)" id="dynatree-transfer"&gt;Import&lt;/a&gt; | &lt;div id="viewname_selector"&gt; &lt;%= form_tag({:controller =&gt; :loopview, :action =&gt; :show}, { :id =&gt; "viewname_form" ,:remote =&gt; true}) do %&gt; &lt;%= collection_select(:viewname, :id, @viewnames, :id, :name, :selected =&gt; @current_viewname_id) %&gt; &lt;% end %&gt; &lt;/div&gt; &lt;% end %&gt; &lt;div id="leftpanel"&gt; &lt;!-- Leftpanel Context menus --&gt; &lt;ul id="myMenu" class="contextMenu"&gt; &lt;li class="rename"&gt;&lt;a href="#rename"&gt;Rename&lt;/a&gt;&lt;/li&gt; &lt;li class="new_child"&gt;&lt;a href="#new_child"&gt;New Child&lt;/a&gt;&lt;/li&gt; &lt;li class="copy"&gt;&lt;a href="#copy"&gt;Copy&lt;/a&gt;&lt;/li&gt; &lt;li class="paste"&gt;&lt;a href="#paste"&gt;Paste&lt;/a&gt;&lt;/li&gt; &lt;li class="delete"&gt;&lt;a href="#delete"&gt;Delete&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;ul id="ProjectMenu" class="contextMenu"&gt; &lt;li class="new_child"&gt;&lt;a href="#new_child"&gt;New Child&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;!-- Leftpanel Tree title --&gt; &lt;div id='dynatree-title' data-project-id='&lt;%= current_project.id %&gt;'&gt; &lt;span&gt;&lt;/span&gt;&lt;%= current_project.name %&gt; &lt;/div&gt; &lt;!-- Leftpanel Dynatree --&gt; &lt;%= render_project_tree(current_project, "tree") %&gt; &lt;!-- Leftpanel "New Child" Form --&gt; &lt;%= render :partial =&gt; "lean_new_child" %&gt; &lt;/div&gt; &lt;!-- Right Panel --&gt; &lt;div id="dynatree-details"&gt; &lt;%= render :template =&gt; 'projects/show' %&gt; &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload