Frage

Is there a way to alter the autocomplete-list after initializing the plugin? I'd like to pass an array of new words for the 'availableTags' and be able to remove the old ones.

This works even after initializing:

$("#mytags").tagit({
    availableTags: ["new_tag_1", "new_tag_2"]
});

But my new tags are in an array and if I try to pass an array variable to availableTags, like below, it doesn't work. Any ideas?

$("#mytags").tagit({
    availableTags: [arrayWithNewAutocompleteTags]
});

How do I manipulate the availableTags-array and pass it an array? There's probably a more "code"-way of doing what I'm trying to do. Basically I'd like a "removeAll" and "createTag" for the availableTags as well.

War es hilfreich?

Lösung

You need to give this way:

// if the tags are in array this way:
arrayWithNewAutocompleteTags = ["new_tag_1", "new_tag_2"];


// then you need to add them this way:
$("#mytags").tagit({
    availableTags: arrayWithNewAutocompleteTags
});
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top