1

我无法通过 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")
4

1 回答 1

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

这是解决方案。

于 2013-01-19T16:47:18.303 回答