1
我有兩個單獨的視圖,它們正在輸出名爲:icons的命名yield塊的內容。兩個content_for所有視圖中的相同良率呈現(Rails 3)
當我打開兩個頁面,我總是看到:圖標塊2個視圖的內容... :-(
視圖1:項目#指數
<% content_for :icons do %>
Project Icons ...
<% end %>
...
查看2 :樹#顯示
<% content_for :icons do %>
<a href="javascript:void(0)" id="dynatree-expand-all">Expand</a>
<a href="javascript:void(0)" id="dynatree-collapse-all">Collapse</a>
<a href="javascript:void(0)" id="dynatree-transfer">Import</a>
<div id="viewname_selector">
<%= form_tag({:controller => :loopview, :action => :show}, { :id => "viewname_form" ,:remote => true}) do %>
<%= collection_select(:viewname, :id, @viewnames, :id, :name, :selected => @current_viewname_id) %>
<% end %>
</div>
<% end %>
而且在application.html.erb呼叫
<div id="icons">
<%= yield :icons %>
</div>
當我加載項目#索引,我只有項目圖標(所以它沒事)。
當我加載樹#指數,我有樹圖標和項目圖標...
我到底做錯了什麼?如何只在樹視圖中獲取樹圖標?
編輯:樹#指數的完整源
<% content_for :head do %>
<title>Dynatree View <%= sicadea %></title>
<%= javascript_include_tag "leanModal/jquery.leanModal.min" %>
<%# For the dynatree %>
<%= stylesheet_link_tag "dynatree/skin/ui.dynatree.css" %>
<%= stylesheet_link_tag "dynatree/skin/ui.dynatree.custom.css" %>
<%= javascript_include_tag "cookie/jquery.cookie.js" %>
<%= javascript_include_tag "dynatree/jquery.dynatree-1.2.4.js" %>
<%= stylesheet_link_tag "contextMenu/jquery.contextMenu.css" %>
<%= javascript_include_tag "contextMenu/jquery.contextMenu-custom.js" %>
<%= javascript_include_tag "contextMenu/jquery.ui.position.js" %>
<%= javascript_include_tag "dynatree.js" %>
<%# for the poin'ts table %>
<%= stylesheet_link_tag "loopview.css" %>
<% end %>
<% content_for :icons do %>
<a href="javascript:void(0)" id="dynatree-expand-all">Expand</a> |
<a href="javascript:void(0)" id="dynatree-collapse-all">Collapse</a> |
<a href="javascript:void(0)" id="dynatree-transfer">Import</a> |
<div id="viewname_selector">
<%= form_tag({:controller => :loopview, :action => :show}, { :id => "viewname_form" ,:remote => true}) do %>
<%= collection_select(:viewname, :id, @viewnames, :id, :name, :selected => @current_viewname_id) %>
<% end %>
</div>
<% end %>
<div id="leftpanel">
<!-- Leftpanel Context menus -->
<ul id="myMenu" class="contextMenu">
<li class="rename"><a href="#rename">Rename</a></li>
<li class="new_child"><a href="#new_child">New Child</a></li>
<li class="copy"><a href="#copy">Copy</a></li>
<li class="paste"><a href="#paste">Paste</a></li>
<li class="delete"><a href="#delete">Delete</a></li>
</ul>
<ul id="ProjectMenu" class="contextMenu">
<li class="new_child"><a href="#new_child">New Child</a></li>
</ul>
<!-- Leftpanel Tree title -->
<div id='dynatree-title' data-project-id='<%= current_project.id %>'>
<span></span><%= current_project.name %>
</div>
<!-- Leftpanel Dynatree -->
<%= render_project_tree(current_project, "tree") %>
<!-- Leftpanel "New Child" Form -->
<%= render :partial => "lean_new_child" %>
</div>
<!-- Right Panel -->
<div id="dynatree-details">
<%= render :template => 'projects/show' %>
</div>
不,這是創建塊chere你可以通過一個content_for添加內容。它不加載樹#索引。 –
從哪裏來:圖標來了?從模型?你可以顯示樹#索引的完整視圖代碼嗎? – Inaccessible
它當然來自<%content_for:icons do%>。在問題 –