0
在我看來,我得到所有頁面
我得到我所有的頁面以及所有的子項和子項。如何獲得樹狀結構如下圖所示:如何動態構建樹狀結構
<% for page in @pages%>
<li id="<%= page.id%>_page">
<div class="link">
#my attributes for the div<
/div>
#here I got the all siblings of that page. But here the structure is of just two
#levels. I need upto n-levels.
<% @childs = page.*descendants* %>
<% if [email protected]? && [email protected]? %>
<% for child in @childs%>
<ol class="child">
<li id="<%= child.id%>_page">
<div class="link">
#my attributes for the div
</div>
</li>
</ol>
<%end%>
<%end%>
</li>
<%end%>
我使用嵌套集,並希望這樣的結構:
page1
page 2
page 3
page 3.1
page 3.2
page3.4
...so on to last child
page 4
page 5
....so on to N-levels...
嘗試..我得到了解決之後...我呈現局部而這又使itself..such爲 – Milind 2012-08-02 09:47:56