xoxco/jQuery-Tags-Input — Issue #45: Can't extract tags from dynamically created tags input
Author: dhyasama
Created: 2012-01-27 17:29:43+00:00
State: open

Hello,

I'm prototyping a page to make use of your plugin. So far so good except for one problem. Obviously the tags need to be serialized at some point. No problem with tags inputs that exist on page load, but if I create one dynamically I can't seem to get the tags out.

Here is the relevant code I run on document.ready:

$("form input[class^='tags']").each(function () { initializeTags(this); });

function initializeTags(el) {
console.log('init ' + $(el).attr('id'));
$(el).tagsInput({ width: '300', defaultText: 'Click to add a keyword' });
}

I have a button that creates a new tags input and calls initializeTags again. It displays properly and I can add and remove tags from it. But when I try to get the tags out for serialization there is nothing there.

Here is that code:

$('#test-save').click(function () {
$('#positive-keyword-groups input.tags.positive').each(function () {
console.log($(this).attr('id') + ' ' + $(this).val());
});
});

The vals are correct for tags inputs that existed on page load but blank for dynamically added tags inputs.

Thoughts? Bug? User error?

Thanks,
Jason Reynolds