微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何设置html数据禁用与rails submit_tag

我有一个RoR应用程序使用引导.我试图将fontawesome html图标标签应用于submit_tag帮助器,但似乎不被支持.当我点击提交时,禁用内容只是显示一个字符串而不是被解释为html,尽管它对于link_to帮助.

这是erb:

<%= form_tag("/home/search",method: "get",class: "form-inline",role: "search",remote: true) do %>
    <div class="form-group">
        <%= text_field_tag(:term,nil,{:class => "form-control","data-html" => true,:value => @term}) %>
    </div>
    <%= submit_tag "Go!",class: "btn btn-transparent",role: "button",'data-disable-with' => "<i class='fa fa-spinner fa-spin'></i> Searching...".html_safe %>    
 <% end %>

以下是当我点击提交时出现的样子:

它与link_to一起工作,但是我不能将text_field_tag的值传递给link_to,否则我将对该解决方案感到满意.我真的宁愿避免自己编写.ajax方法,并使用javascript来操纵按钮值.有关如何使用标准FormHelper标签解决此问题的任何建议?提前谢谢了.

解决方法

您应该尝试将submit_tag更改为button_tag,如下所示:
<%= button_tag "Go!",'data-disable-with' => "<i class='fa fa-spinner fa-spin'></i> Searching...".html_safe %>

原文地址:https://www.jb51.cc/html/229954.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐