Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap Tags Input how to bind function to event itemAdded and itemRemoved?

There is no documentation about events on the website, any ideas ?http://timschlechter.github.io/bootstrap-tagsinput/examples/

like image 611
beratuslu Avatar asked Dec 05 '22 07:12

beratuslu


1 Answers

Maybe the author have not had the time to document it yet? :-) But, bootstrap-tags triggers two signifcant events : itemAdded and itemRemoved.

Here is an example you can try out :

markup :

<input type="text" value="Amsterdam,Washington,Sydney,Beijing,Cairo" data-role="tagsinput" placeholder="Add tags" id="tag"/>

event listeners :

$("#tag").on('itemAdded', function(event) {
    console.log('item added : '+event.item);
});
$("#tag").on('itemRemoved', function(event) {
    console.log('item removed : '+event.item);
});

Here you go on your question.

like image 198
davidkonrad Avatar answered Dec 07 '22 23:12

davidkonrad