How to use @yaireo/tagify - 1 common examples

To help you get started, we’ve selected a few @yaireo/tagify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tribe29 / checkmk / web / htdocs / js / modules / forms.js View on Github external
return;
        }

        let max_labels = element.getAttribute("data-max-labels");
        let world = element.getAttribute("data-world");

        let ajax_obj;
        let tagify_args = {
            pattern: /^[^:]+:[^:]+$/,
        };

        if (max_labels !== null) {
            tagify_args["maxTags"] = max_labels;
        }

        let tagify = new Tagify(element, tagify_args);

        tagify.on("invalid", function(e) {
            let message;
            if (e.type == "invalid" && e.detail.message == "number of tags exceeded") {
                message = "Only one tag allowed";
            } else {
                message = "Labels need to be in the format <tt>[KEY]:[VALUE]</tt>. For example <tt>os:windows</tt>.";
            }

            $("div.label_error").remove(); // Remove all previous errors

            // Print a validation error message
            var msg = document.createElement("div");
            msg.classList.add("message", "error", "label_error");

            msg.innerHTML = message;

@yaireo/tagify

lightweight, efficient Tags input component in Vanilla JS / React / Angular [super customizable, tiny size & top performance]

MIT
Latest version published 1 day ago

Package Health Score

65 / 100
Full package analysis

Popular @yaireo/tagify functions