2013-10-17 19 views
0

我試圖通過它嵌套我的菜單項無法顯示。簡單的導航未顯示在Rails 3上使用引導的嵌套項目

吉斯特https://gist.github.com/poc7667/7019484

它應該顯示在我的菜單兩個net.item。但事實並非如此。

我猜這個問題是由於我必須在輸出html中做一些css,但如何?

primary.item :urltests, 'Network/Documentation', root_path do |net_docs| 

    net_docs.item :net, "URL Command", welcome_af_form_path do |net|   
    net.item :vvtk, "VIVOTEK", urltests_path 
    net.item :sony, "SONY", sony_url_command_automation_tests_path 
    end 

    # net_docs.item :div, "Translate Strings", :class => 'dropdown-header' 
    # net_docs.item :div, "divider" , :class => 'divider' 
    # net_docs.item :trans_db, 'Firmware', translates_path 
end 

這裏看看

enter image description here

這裏是我的包列表

Gems included by the bundle: 
    * actionmailer (3.2.12) 
    * actionpack (3.2.12) 
    * activemodel (3.2.12) 
    * activerecord (3.2.12) 
    * activeresource (3.2.12) 
    * activesupport (3.2.12) 
    * arel (3.0.2) 
    * atomic (1.1.14) 
    * awesome_print (1.1.0) 
    * bcrypt-ruby (3.1.2) 
    * bootstrap-sass (2.3.2.2) 
    * builder (3.0.4) 
    * bundler (1.3.5) 
    * cancan (1.6.10) 
    * carrierwave (0.9.0) 
    * celluloid (0.15.1) 
    * coffee-rails (3.2.2) 
    * coffee-script (2.2.0) 
    * coffee-script-source (1.6.3) 
    * connection_pool (1.1.0) 
    * devise (3.1.1) 
    * erubis (2.7.0) 
    * execjs (2.0.1) 
    * haml (4.0.3) 
    * hike (1.2.3) 
    * hirb (0.7.1) 
    * hirb-unicode (0.0.5) 
    * i18n (0.6.5) 
    * journey (1.0.4) 
    * jquery-datatables-rails (1.11.2 494f752) 
    * jquery-rails (3.0.4) 
    * jquery-ui-rails (4.0.4) 
    * json (1.8.0) 
    * mail (2.4.4) 
    * mime-types (1.25) 
    * mini_portile (0.5.1) 
    * multi_json (1.8.0) 
    * nokogiri (1.6.0) 
    * orm_adapter (0.4.0) 
    * pg (0.17.0) 
    * polyglot (0.3.3) 
    * quiet_assets (1.0.2) 
    * rack (1.4.5) 
    * rack-cache (1.2) 
    * rack-ssl (1.3.3) 
    * rack-test (0.6.2) 
    * rails (3.2.12) 
    * railties (3.2.12) 
    * rake (10.1.0) 
    * rdoc (3.12.2) 
    * redis (3.0.4) 
    * redis-namespace (1.3.1) 
    * rest-client (1.6.7) 
    * sass (3.2.10) 
    * sass-rails (3.2.6) 
    * sequel (3.20.0) 
    * sidekiq (2.14.0) 
    * simple-navigation (3.11.0) 
    * simple-navigation-bootstrap (1.0.0) 
    * sinatra (1.0) 
    * sprockets (2.2.2) 
    * sqlite3 (1.3.8) 
    * taps (0.3.24) 
    * thor (0.18.1) 
    * thread_safe (0.1.3) 
    * tilt (1.4.1) 
    * timers (1.1.0) 
    * tinymce-rails (4.0.2) 
    * tlsmail (0.0.1) 
    * treetop (1.4.15) 
    * twitter-bootstrap-rails (2.2.8 40ffd56) 
    * tzinfo (0.3.37) 
    * uglifier (2.2.1) 
    * unicode-display_width (0.1.1) 
    * warden (1.2.3) 
    * will_paginate (3.0.4) 

輸出HTML

<div class='navbar'> 
      <div class='navbar-inner'> 
      <div id='top_navi'><ul class="nav"><li id="remotefocus"><a href="/">Image</a></li><li class="active dropdown" id="urltests"><a href="/" class="dropdown-toggle active" data-target="#" data-toggle="dropdown">Network/Documentation <b class="caret"></b></a><ul class="dropdown-menu"><li class="active dropdown" id="network"><a href="/welcome/af_form" class="dropdown-toggle active" data-target="#" data-toggle="dropdown">URL Command <b class="caret"></b></a><ul class="tabs span16 dropdown-menu"><li class="active simple-navigation-active-leaf" id="vvtk"><a href="/urltests" class="active">VIVOTEK</a></li><li id="sony"><a href="/sony_url_command_automation_tests">SONY</a></li></ul></li><li id="trans_db"><a href="/translates">Firmware</a></li></ul></li><li id="translate"><a href="/">Translate String</a></li></ul></div> 

回答

1

如果您需要完整的導航樹要呈現所有的時間(獨立於當前URL的),你需要調用render_navigation設置爲true的expand_all選項:

render_navigation :expand_all => true, ... 

如果不通過這個選項,簡單的導航通常只呈現活動的主要導航項目的子導航(取決於當前的URL)。

+0

做了你的嘗試:expand_all選項如上所述? –

+0

哦,它沒有工作。我可以在DOM中看到子菜單。但不顯示在頁面 – newBike

+0

如果您可以在DOM中看到它,但不在頁面上,請確保它們可見。也許你有隱藏它們的CSS規則? –

0

@ poc。 正如我從你的問題理解,你有'子菜單'的問題。
dropdown-submenuBootstrap 2,它應該像下面的使用:

<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel"> 
    ... 
    <li class="dropdown-submenu"> 
    <a tabindex="-1" href="#">More options</a> 
    <ul class="dropdown-menu"> 
     ... 
    </ul> 
    </li> 
</ul> 

的問題是,寶石simple-navigation-bootstrap,您可以使用它創建引導菜單,不生成該類。

我剛剛創建了另一個創業板simple_navigation_renderers來解決這個問題,並提供了創建Bootstrap'標題'和'分隔線'的簡單方法。有可能添加任何類型的圖標(庫)。實際上,有兩個渲染器:用於Bootstrap 2和Bootstrap 3;)
試試吧。我認爲它會幫助你。我希望你會喜歡它。

+0

該寶石看起來很有前途。我應該將它添加到簡單導航wiki嗎? –

+0

當然,安迪。我喜歡這個主意。如果你有任何改進的想法或建議,我是全部耳朵。 – shpakvel

+0

再一次,根據你的要點,@ poc顯然你已經嵌套了'dropdown-menu',並用'dropdown'包裝起來。但只有第一級'下拉菜單'纔是正確的。對於嵌套的'dropdown-menu',在[Bootstrap 2](http://getbootstrap.com/2.3.2/components.html#dropdowns)中有特殊的類'dropdown-submenu',正如我上面提到的那樣。您應該使用它('dropdown-submenu'),而不是'dropdown',以便嵌套**'下拉菜單。在Bootstrap 3中沒有嵌套的「下拉菜單」,但可以自己創建它。 – shpakvel