0

无法显示带有 aa''a@a.com 等值的 jQuery 移动复选框

@contact_info = [{:source_id=>40021, :object=>"148302514605161.2", :account_number=>"332950", :contact_type=>"E", :contact_value=>"aa''a@a.com", :sequence=>"1"}, {:source_id=>40021, :object=>"148302514605162.2", :account_number=>"332950", :contact_type=>"E", :contact_value=>"asdf@asd.org", :sequence=>"2"}, {:source_id=>40021, :object=>"148302514605163.2", :account_number=>"332950", :contact_type=>"E", :contact_value=>"dog@g.com", :sequence=>"3"}, {:source_id=>40021, :object=>"148302514605164.2", :account_number=>"332950", :contact_type=>"E", :contact_value=>"gh'g@ff.bn", :sequence=>"4"}, {:source_id=>40021, :object=>"148302514605165.2", :account_number=>"332950", :contact_type=>"F", :contact_value=>"2579525795", :sequence=>"5"}]

在 .erb 文件中

 <table id="previous_email_fax_list">
      <% if @contact_info. size > 0 %>
      <% @contact_info.each do |contact|%>  
        <tr>
          <td style="border:1px solid black;"> 
            <div class="email_fax_check">
              <input type="checkbox" name="<%= contact.contact_value %>" id="<%= contact.contact_value %>"  class="custom" />
              <label for="<%= contact.contact_value %>"><br/></label>
            </div>
            <div class="email_fax_label">
              <% if contact.contact_type == "E" %>
                <%= contact.contact_value %>
              <% elsif contact.contact_type == "F" %>
                <%= number_to_fax(contact.contact_value) %>
              <% end %>
            </div>
          </td>
        </tr>
      <% end %>
      <% else %>
        <tr>
          <td align='center'>
             No email addresses or fax numbers found for this account
          </td>
        </tr>
      <% end %>
      </table>

我正进入(状态Error: Syntax error, unrecognized expression: for='gh'g@ff.bn']

4

1 回答 1

0

我复制了这段代码:

<input type="checkbox" name="<%= contact.contact_value %>" id="<%= contact.contact_value %>"  class="custom" />
          <label for="<%= contact.contact_value %>"><br/></label>

并将其添加到现有的应用程序视图中,添加变量,删除contact.和删除所有双引号以进行测试:

<% contact_value = "'gh'g@ff.bn'" %>
          <input type="checkbox" name=<%= contact_value %> id=<%= contact_value %> class="custom" />
          <label for=<%= contact_value %>><br/><%= contact_value %></label>

我得到:

复选框图像

没有任何错误。<%= contact.contact_value %>在视图代码中不带任何引号的情况下试一试。

于 2013-09-13T15:32:23.223 回答