victor-valencia / bootstrap-iconpicker

A simple icon picker
https://victor-valencia.github.com/bootstrap-iconpicker/
MIT License
377 stars 140 forks source link

Reset Iconpicker #48

Open henningwerner opened 8 years ago

henningwerner commented 8 years ago

How is it possible to reset the Icon picker? I want to set during the runtime another icon.

I see it's possible with: .iconpicker('setIcon', 'fa-wifi') The problem here is the icon picker doesn't shows the selected icon page.

I've done several trials to reset it via:

1.) .iconpicker('reset') 2.) Initialize via JS and clear content before:

$('#editCategoryIcon').empty().iconpicker({
  align: 'left',
  footer: false,
  icon: icon,
  iconset: 'fontawesome',
  rows: 5,
  search: true,
  searchText: 'Suchen...'
});

But I can't figure it out, any ideas?

pbenard73 commented 7 years ago

Something like this fiddle using a clone ?

$('#my_checkbox').on('change', function(){
    if ($(this).is(':checked')) {
    $('#my_iconpicker').iconpicker();
  } else {
    var source = $('#my_iconpicker');
    source.unbind().empty();
    var clone = source.clone(false);
    source.remove();
    $('label').before(clone);
  }
});

$('#setIcon').on('click', function(){
    $('#my_iconpicker').iconpicker('setIcon', 'fa-wifi')
})
eformx commented 5 years ago

Solution is to clear the value (val)... $('.notify_icon').val('').iconpicker('setIcon', notify_icon);

harshitpeer commented 3 years ago

I just got some simply reset option here

$('#iconpicker').iconpicker() $('#iconpicker').iconpicker('setIcon', 'empty')