通过data-erb-id删除元素

时间:2013-01-19 16:30:40

标签: ruby-on-rails-3 spree deface

我无法通过data-erb-id删除元素。

来自http://deface.heroku.com/的代码:

 <p class="field" data-erb-id='&lt;%="#{address_id}address1" %&gt;'>
    <code erb-loud> form.label :address1, t(:street_address) </code><span class="required">*</span><br><code erb-loud> form.text_field :address1, :class => 'required' </code>
  </p>
  <p class="field" data-erb-id='&lt;%="#{address_id}address2" %&gt;'>
    <code erb-loud> form.label :address2, t(:street_address_2) </code><br><code erb-loud> form.text_field :address2 </code>
  </p>

这是我的选择器:

p[data-erb-id='<%="#{address_id}address2" %>']

匹配一次,正是我需要的

这是我的结束选择器:

p[class='field']

结果是:

<p class="field" id='<%="#{address_id}address1" %>'>
    <%= form.label :address1, t(:street_address) %><span class="required">*</span><br><%= form.text_field :address1, :class => 'required' %>
  </p>

  <p class="field" id='<%="#{address_id}country" %>'>
    <%= form.label :country_id, t(:country) %><span class="required">*</span><br><span id='<%="#{address_id}country-selection" %>'>
      <%= form.collection_select :country_id, available_countries, :id, :name, {}, {:class => 'required'} %>
    </span>
  </p>

所以我需要的块已被移除。

我的应用程序中的这个声明不会删除任何内容:

Deface::Override.new(:virtual_path  => "spree/address/_form",
                     :remove => "p[data-erb-id='<%=\"\#{address_id}address2\" %>']",
                     :name          => "checkout_address")

1 个答案:

答案 0 :(得分:0)

Deface::Override.new(:virtual_path  => "spree/address/_form",
                     :remove => "p[data-erb-id='<%=\"\#{address_id}address2\" %>']",
                     :name          => "checkout_address")

这是解决方案。