我在下面的代码中遇到了syntaxt错误。
有人可以帮助我。
<%= button_tag :class => 'pull-right margin-clear btn btn-sm btn-default-transparent btn-animated notify-class', :type => :submit,
:id =>"notify-class<%=product.master.id%>" :style=>'display:none'
:data-toggle => "modal" , :data-target => "#myModal" >
Notify me!<i class="fa fa-bell" style ="margin-left: 10px;"></i>
<% end %>
答案 0 :(得分:1)
您之前缺少逗号:style和before:data-toggle - 这是更正后的代码:
<%= button_tag :class => 'pull-right margin-clear btn btn-sm btn-default-transparent btn-animated notify-class', :type => :submit,
:id =>"notify-class<%=product.master.id%>", :style=>'display:none',
:data-toggle => "modal" , :data-target => "#myModal" >
Notify me!<i class="fa fa-bell" style ="margin-left: 10px;"></i>
<% end %>
答案 1 :(得分:0)
首先,您需要在do
:
button_tag
<%= button_tag :class => 'pull-right margin-clear btn btn-sm btn-default-transparent btn-animated notify-class', :type => :submit,
:id =>"notify-class<%=product.master.id%>" :style=>'display:none'
:data-toggle => "modal", :data-target => "#myModal" do %>
Notify me! <i class="fa fa-bell" style ="margin-left: 10px;"></i>
其次,您需要修复"notify-class<%=product.master.id%>"
。我不确定您在此处尝试做什么,但您在现有&lt;%=%&gt;中注入了<%= %>
个ERB标记。为你的button_tag
。如果您尝试插入字符串,请使用:"notify-class#{product.master.id}"
,只要定义了product
,该工作就会有效。