【问题标题】:Ruby get cancel to be button and not linkRuby 取消成为按钮而不是链接
【发布时间】:2017-12-13 11:38:26
【问题描述】:

我有一些 ruby​​ 代码来创建一个基本的博客。

我想要允许用户在更新密码时更新或取消的按钮。这是在“应用程序助手”中

我希望这些作为按钮,但不确定如何使“取消”按钮返回。它目前只是 java 脚本和文本,但更新用户是一个按钮。

代码如下

module ApplicationHelper


# Creates a submit button with the given name with a cancel link
  # Accepts two arguments: Form object and the cancel link name
  def submit_or_cancel(form, name='Cancel')
    form.submit + " or " +
      link_to(name, 'javascript:history.go(-1);', :class => 'cancel')
  end
end

【问题讨论】:

    标签: ruby-on-rails-3 button cancel-button


    【解决方案1】:

    我不是这个的粉丝,但你可以尝试做这样的事情

    module ApplicationHelper
    # Creates a submit button with the given name with a cancel link
      # Accepts two arguments: Form object and the cancel link name
      def submit_or_cancel(form, name='Cancel')
        form.submit + " or " +
          link_to(name, '#',:onclick => 'history.go(-1);', :class => 'cancel')
      end
    end
    

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2018-09-26
      • 1970-01-01
      • 2015-03-17
      • 2010-10-10
      • 2018-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多