1
I’m using materialize chips in my project, but I wanted to avoid this standard behavior of adding the same empty tag, for example:
How do I stop this and enter the tag only when there is at least one character?
The closest I came was:
$('.chips').on('chip.add', function(e, chip){
console.log(chip);
var chip = chip.tag;
if(!chip.trim()){
alert('CHIP VAZIO!');
//aqui gostaria de fazer algo do tipo chip.remove() porém da erro
}
});
Amigo puts at least the version of Materialize that is used and your HTML, only with the image can not help you much
– hugocsl
@hugocsl this example is of the materialize itself.
– user133681
Materialize has many "flaws", loose ends that were not tied up - I can not say if due to lack of knowledge or if it was their goal. It seems that it was done in a hurry and in a way that was visibly pleasant. In
options
of its element, there is the propertyonChipAdd
. Try to use it to validate the added value.– Woss
On the documentation page JS, I don’t know much, but I believe someone more experienced will know how to help you https://materializecss.com/chips.html at the end of the page te os scrpts...
– hugocsl
I’ll do some research..
– user133681
@Andersoncarloswoss I did through on chip add, but I did not find any way to delete this chip through the code. Know something?
– user133681