我有两个单独的视图,它们为名为 :icons 的命名 yield 块输出内容。
当我加载这两个页面时,我总是在 :icons 中看到 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>
当我加载 Projects#index 时,我只有项目图标(所以没关系)。
当我加载 Tree#index 时,我有树图标和项目图标......
我究竟做错了什么 ?如何仅获取树视图中的树图标?
编辑:树#index的完整来源
<% 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>