I'm trying to use the jQuery tags input开发者_开发问答 plugin, but there is not much documentation. I need to define event handlers for when a tag is added or removed. I guess I could make an object watch on the output string to determine this, but that is quite awkward.
Looking into the source code for the tags input plugin, there currently seems to be support for callbacks for addTag()
and removeTag()
.
there appears to be 3 callback handlers you can register when you create the tag list. They are:
- onAddTag
- onRemoveTag
- onChange
when you create your tag list, try setting functions to these on the options object you pass it:
$(selector).tagsInput({
onAddTag: function(value){
// Do Stuff
},
onRemoveTag: function(value){
// Do Stuff
},
onChange: function(tagList, value){
// Do Stuff
}
});
Note: I haven't tested this, but the source code indicates this should work.
精彩评论