Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow autocomplete to be suggestion #13

Open
drake7707 opened this issue Jul 17, 2020 · 1 comment
Open

Allow autocomplete to be suggestion #13

drake7707 opened this issue Jul 17, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@drake7707
Copy link

Currently freeInput doubles as search filter for the dropdown but the user can't add their own tags anymore once a source is initialized. I'd like the dropdown to show tags that are already available but still allow the user to create new tags.

Currently I'm doing a workaround by adding a link in the no results label that adds the current search text but it's not great

    new BulmaTagsInput(document.getElementById("tags"), {
        freeInput: true,
        allowDuplicates: false,
        caseSensitive: false,
        itemValue: "value",
        itemText: "name",

        noResultsLabel: "No results, <a class='lnkAddCurrentTag'>add current search text</a>",
        source: [{ name: "work", value: "work" },  { name: "school", value: "school" } ]
    });
    $(document).on("click", ".lnkAddCurrentTag", null, () => {
        var tags = <any>$("#tags").get(0);
        var searchText = tags.BulmaTagsInput().input.value;
        tags.BulmaTagsInput().add({ name: searchText, value: searchText });
        $(tags.BulmaTagsInput().container).removeClass("is-active");
        tags.BulmaTagsInput().input.value = "";
    });
@drake7707
Copy link
Author

I found a better solution, by adding a datalist with id="null" next to the tag it will suggest those entries during freeInput.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants