Search code examples
jquerymaterialize

how to deleted item materialize chips


I want to let me know when I delete one of the items or ask for confirm before deleting

$('.chips.the-best').chips({
    onChipDelete:function(){
     cosnole.log('deleted item')   
   }
});

Solution

  • file: materialize.js line 8150

    $(document).ready(function () {
        // Handle removal of static chips.
        $(document.body).on('click', '.chip .close', function () {  
          var $chips = $(this).closest('.chips');
          if ($chips.length && $chips[0].M_Chips) {
            return;
          }
          $(this).closest('.chip').remove();
    
        });
      });