2014-06-04 33 views
0

視窗8.1 滑軌4.1 紅寶石2.0使當某個視圖顯示軌道

我在視圖/佈局定義爲我的應用程序的菜單,並且這些中的一個是在那裏我有報頭中的菜單項出現菜單項。還有一些額外的部分以_header.html.erb形式呈現。

我想只有當我渲染views/pages/index時纔會出現一個額外的菜單。我如何去做這件事?

回答

0

我想用Javascript看看。你有沒有試過聽該頁面的特定主體類?每個主體獲得一個動態生成的class =「controller action」屬性。如果您偵聽body.controller.action,您將遇到觸發您顯示(或隱藏)菜單項的事件。

僞代碼可能看起來像:

I want a new menu to appear for controller1, action1 

when any action fires in any controller 
    if the class of the body element has both class "controller1" and class "action1" 
     menu.show() 
    else 
     menu.hide()