bootstrap-iconpicker
bootstrap-iconpicker copied to clipboard
Does not work when cloned
Hello, the plugin is promising and possibly the best in its kind. I have a problem like I do for the cloned iconpicker to work correctly, here's the example: https://jsfiddle.net/iLen/r87e5nh5/1/
help.
Just have to set false as clone function argument.
The code with toggle true to false in clone function
jQuery(".aaaa").iconpicker();
jQuery(".a_clone").on("click",function(){
$(".aaaa").clone(false).insertAfter(".iconpicker_cloned");
jQuery(".aaaa").iconpicker();
});
With the clone: false this works fine, but if I do this I lose the events of the other input example: onclick, please check this example: example Please check param the .clone link
Yes it could be better, but the main bundle seems to not be maintained....
Here is a hack just for your case : fiddle
$(".base_iconpicker").iconpicker();
$(".btn_clone").on("click",function(){
var div_cloned = $(".div_to_clone").clone(true).removeClass('div_to_clone').insertAfter(".iconpicker_cloned");
var errorClonePicker = div_cloned.find('.base_iconpicker');
errorClonePicker.clone(false).insertAfter(errorClonePicker).iconpicker();
errorClonePicker.remove();
});
$(".div_to_clone input[type='text']").on("click",function(){
alert("event on click in text input");
});