Question

Does anyone know if the tagit jQuery plugin has a public method for removing just 1 specified tag from the list?

I saw there is for removing (clear) all tags from the list, but I would need to remove only 1 tag :P

Also, how to call all the public methods from outside of tagit() call?

Was it helpful?

Solution

No, it does not. Just wrap a public function around _popTag in the widget code, e.g.

removeTag : function(label,value) {
    this._popTag(label, value);
}

and call it like this:

$(myElement).tagit("removeTag", label, value);

OTHER TIPS

If you're using the jQuery UI Tag-it plugin by aehlke, then these instructions will provide the plugin with this functionality:

Syntax:

// removes the tag called "outdated-tag"
$("#mytags").tagit("removeTagByName","outdated-tag");

Add this method right below the removeAll method in the tag-it.js file:

removeTagByName: function(tagName) {
        var that = this;
        this.removeTag(this.tagList.children('.tagit-choice').find("input[value='"+
                tagName +"']").parent(), null);
}

NOTE: You are modifying a code library! So be sure to document what you're doing with clear code comments and otherwise documenting this change so that when you or a colleague update the plugin to another version, you're sure to include this functionality and not be baffled by why things suddenly stopped working ;)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top