qwww
qwww

Reputation: 1363

How to get tags typed using tag manager

I have an input field which will accept tags. Once I am done with those tag additions, how can I get the values out to save it to my database?

I am using the tagManager library to make this tag addition easily.

$(".tm-input").tagsManager();
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/tagmanager/3.0.2/tagmanager.min.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tagmanager/3.0.2/tagmanager.min.js"></script>

<input type="text" name="tags" placeholder="Type the subsystem name and press enter" class="form-control tm-input tm-input-info" autocomplete="off" />

http://jsfiddle.net/0y7a5kfu/2/

Upvotes: 2

Views: 204

Answers (1)

Rory McCrossan
Rory McCrossan

Reputation: 337580

According to the documentation you can use tagsManager('tags') to retrieve the input:

$('.tm-input').tagsManager();

$('button').click(function() {
  console.log($('.tm-input').tagsManager('tags'))
})
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/tagmanager/3.0.2/tagmanager.min.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tagmanager/3.0.2/tagmanager.min.js"></script>

<input type="text" name="tags" placeholder="Type the subsystem name and press enter" class="form-control tm-input tm-input-info" autocomplete="off" />
<button>Get</button>

Upvotes: 3

Related Questions