xoxco / jQuery-Tags-Input

Magically convert a simple text input into a cool tag list with this jQuery plugin.
http://xoxco.com/projects/code/tagsinput/
2.29k stars 826 forks source link

Trigger 'change' when updating TagsField. #255

Open esbanarango opened 9 years ago

esbanarango commented 9 years ago

Is it possible to trigger the change event when updating the TagsField?

$.fn.tagsInput.updateTagsField = function(obj,tagslist) {
    var id = $(obj).attr('id');
    $(obj).val(tagslist.join(delimiter[id]));
    $(obj).trigger('change'); // <------
};
lucknerjb commented 9 years ago

This is the kind of functionality that should be exposed via a callback function or a config option. Most likely the former.

Unlike invoking blur or focus on an element, I'm a little weary of invoking the change event because it could very easily be tied to other code and it's not an event you expect a tags plugin to trigger necessarily.