Yapapaya / jquery-cloneya

A jquery plugin to clone DOM elements
MIT License
76 stars 28 forks source link

Why child-selector? #37

Closed gchokeen closed 9 years ago

gchokeen commented 9 years ago

In the lastest plugin release 1.0.0, cloneya using child-selector for all the delete & clone button. It making us to use strict & standard structure, is it really required?

When I work accross the bootstrap form, I faced problem below structure

          <div class="clone-wrapper">
         <div class="input-group form-group toclone">
              <input type="text" class="form-control" id="field_label" placeholder="Field Label">  
              <div class="input-group-addon"><a href="javascript:void(0);" class="clone"><i class="glyphicon glyphicon-plus"></i></a></div>
      </div>
      </div>

This one solved

<div class="input-group-addon clone"><a href="javascript:void(0);"><i class="glyphicon glyphicon-plus"></i></a></div>

Do you think it's really important to do that!

code-poel commented 9 years ago

@gchokeen You can actually do this by simply specifying the CSS selector route down to the .clone element. As you can see in the source, the cloneButton config value is just appended to the toClone selector. So you can do something like:

$('.clone-wrapper').cloneya({
    cloneButton: 'div.card > div.card-head > div.tools > div.btn-group > a.clone'
})
gchokeen commented 9 years ago

Yep, that's extra effort, but it still make sense!