alexgorbatchev / jquery-textext

A super awesome, customizable text input supporting tags, autocomplete, ajax and other goodness in a crazy cool a-la cart way.
http://textextjs.com
MIT License
1.27k stars 202 forks source link

Method request: removeAllTags() #186

Open Fabryprog opened 9 years ago

Fabryprog commented 9 years ago

Hello everyone,

today i will loop current tags to remove them

It would be nice to have a method "removeAllTags()"

King regards

sneha27 commented 9 years ago

Try using clear plugin.. Or add below code for some event

someevent: { var self = jQuery(this);

    // check if the tags plugin is present
    if(typeof self.core()._plugins.tags != 'undefined')
    {
        // it is! remove all tags 
        var elems = self.core()._plugins.tags.tagElements();
        for(var i =0; i < elems.length;i++)
        {
            self.core()._plugins.tags.removeTag($(elems[i]));
        }
    }
    // clear the text from the search area
    self.val('');
    self.core().getFormData();

}

Fabryprog commented 9 years ago

@sneha27 yours is a workaround!

I created this issue to delete this horrible workaround in my source code :+1:

Fabryprog commented 9 years ago

+1