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

Remove all tags/Reinitialize #31

Open
karan173 opened this issue Mar 23, 2014 · 5 comments
Open

Remove all tags/Reinitialize #31

karan173 opened this issue Mar 23, 2014 · 5 comments

Comments

@karan173
Copy link

How can we remove all tags from the input box?

@maxwells
Copy link
Owner

The library itself doesn't support it. Is the use case that a user would want to clear all the tags at once?

You could clear them all with something like (nb: there may be syntax errors here):

var tagger = $('.tags').getTags();
var currentTags = tagger.getTags();
var i;
for (i = 0; i < currentTags.length; i++) {
  tagger. removeTag(currentTags[i]);
}

@hosseinimh
Copy link

I had the same problem, then I created a tricky solution:
$('#div-input-tag-holder').html('<input type=text id=tags');
So I rewrite input elemnt into its div holder.

@deedarb
Copy link

deedarb commented Feb 17, 2015

couldn't find destroy method which is needed for SPA applications for cleaning resources...
are you planning to add it?

@havok2063
Copy link

@maxwells I second this request. This seems like a basic requirement. The code that you provide only removes all tags up to the last one. Why doesn't it also remove the last tag as well? Why do you have a removeTag function and a removeLastTag? Couldn't you take this loop and stick it in a new function called removeTags()?

iamsalmanafzal added a commit to iamsalmanafzal/bootstrap-tags that referenced this issue Apr 27, 2017
…e issue "Remove all tags/Reinitialize maxwells#31" Can be view in demo3.html
@nikulchauhan
Copy link

I have tried some workaround for this it works for me pefectly.
var tagData = $("#small").tags().tagData;
if (tagData.length > 0)
{
$.each( tagData, function( index, value ){
for(var tItem=0 ; tItem < tagData.length;)
{
$("#small").tags().removeTag(tagData[tItem]);
}
});
}

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

No branches or pull requests

6 participants