简体   繁体   English

带有tabs_on_rails插件的定制Tab Builder

[英]custom Tab Builder with tabs_on_rails plugin

I have use tabs_on_rails plugin to do tabs view. 我已经使用tabs_on_rails插件来进行标签视图。 and its documentation told me that we can custom a builder to override methods like 它的文档告诉我,我们可以自定义构建器以覆盖类似

  • open_tabs: the method called before the tab set open_tabs:制表符集之前调用的方法
  • close_tabs: the method called after the tab set close_tabs:制表符集之后调用的方法
  • tab_for: the method called to create a single tab item tab_for:用于创建单个选项卡项目的方法

the problem is I don't know where to put the override code? 问题是我不知道将替代代码放在哪里? Does anyone can help me? 有人可以帮助我吗?

@Topley is right but not enough. @Topley是正确的,但还不够。 You should put the particular class input /lib and name it as menu_tab_builder.rb Then you will find that it still doesn't work because of Rails3. 您应该将特定的类输入/ lib命名为menu_tab_builder.rb。然后您会发现它由于Rails3仍然不起作用。 In addition, you need to add open_tabs and close_tabs function. 另外,您需要添加open_tabsclose_tabs函数。

# the following is necessary to make this rails3 compatible
def open_tabs(options = {})
   @context.tag("ul", options, open = true)
end
# the following is necessary to make this rails3 compatible
  def close_tabs(options = {})
    "".html_safe
  end

Good luck! 祝好运!

如果将定制构建器类放在Rails应用程序的/lib目录中的文件中,那么它将由Rails自动加载。

要将定制构建器类文件放在应用程序的/ config / initializers目录中,然后重新启动服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM