我的视图有一个简单的导航:
SimpleNavigation::Configuration.run do |navigation|
navigation.active_leaf_class = 'active'
navigation.items do |primary|
primary.item :profile,'Profile', edit_user_path do |profile|
profile.item :basic, 'Basic Information', edit_user_path
profile.item :additional, 'Addditional Details', additional_details_user_path
profile.dom_class = 'nav nav-list'
end
primary.item :notifications, 'Notifications', notification_preferences_user_path do |notification|
notification.item :notificatin_preference, 'Notification Preferences', additional_details_user_path
notification.dom_class = 'nav nav-list'
end
primary.dom_class ='nav nav-pills' 结束 端
其他详细信息是另一种与编辑无关的方法,因此当我点击该链接时它不会突出显示主要配置文件链接。我该怎么办呢?我在路线中的用户资源是这样的:
resources :users do
member do
get :network
put :peer_tagged_expertise_list
get :qr_code
get :qr_code_image
get :about_you
get :timeline
get :network_tagcloud
get :user_tagcloud
get :settings
get :notification_preferences
get :additional_details
end
collection do
get :test
get :followers
end
resource :networks
end
答案 0 :(得分:1)
获取更多信息后的新答案
简单导航中使用的结构化代码不会自动调整您的路线。
要获得/users/1/profile/additional_details
,您的路线应包含user =>的嵌套profile =>额外细节。
生成时,路径应该类似于additional_details_user_profile_path
。这解决了URL问题,但我不确定它是否能解决Bootstrap的突出显示问题。
旧答案 对于简单导航,请使用
navigation.active_leaf_class="active"
设置您的活动导航项目类。对于Bootstrap,该项应归类为active
。
SimpleNavigation::Configuration.run do |navigation|
navigation.active_leaf_class = "active" # Added this line
navigation.items do |primary|
primary.item :profile,'Profile', edit_user_path do |profile|
profile.item :basic, 'Basic Information', edit_user_path
profile.item :additional, 'Addditional Details', additional_details_user_path
profile.dom_class = 'nav nav-list'
end
primary.item :notifications, 'Notifications', notification_preferences_user_path do |notification|
notification.item :notificatin_preference, 'Notification Preferences', additional_details_user_path
notification.dom_class = 'nav nav-list'
end