remove element by data-erb-id

476 Views Asked by At

I can't remove element by data-erb-id.

Here a code from 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>

Here is my selector:

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

It matches one time, exactly what I need

Here is my closing selector:

p[class='field']

The result is:

<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>

So the block I need has been removed.

This one declaration in my app doesn't remove anything:

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

There are 1 best solutions below

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

Here is the solution.