Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Can't extract tags from dynamically created tags input #45

Closed
dhyasama opened this issue Jan 27, 2012 · 1 comment
Closed

Can't extract tags from dynamically created tags input #45

dhyasama opened this issue Jan 27, 2012 · 1 comment

Comments

@dhyasama
Copy link

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

@dhyasama
Copy link
Author

User error :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant