Reputation: 2686
this is the html and js part. So as you can see when i clicked on the class(reply
) I have to select an option from the dropdown. I do not want that. I want to be prepopulated (tagit) when i clicked on the class (reply
). How can i do that ? thx
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/tag-it.js" type="text/javascript" charset="utf-8"></script>
<p class = "reply">Reply</p>
<input id="tos" name="tos" >
<script type="text/javascript">
$(document).ready(function () {
});
$(".reply").click(function(){
reply_person = "AAAAA,BBBBB,CCCCC";
var tag = reply_person.split(",");
//$('#tos').tagit('createTag', "tag");
$('#tos').tagit({
availableTags: tag,
showAutocompleteOnFocus: true
});
});
</script>
Upvotes: 0
Views: 1184
Reputation: 6042
You're nearly there - two problems I can see.
document.ready
before you add the tokens.Try something like this:
$(document).ready(function () {
$('#tos').tagit({
availableTags: tag,
showAutocompleteOnFocus: true
});
});
$(".reply").click(function(){
reply_person = "AAAAA,BBBBB,CCCCC";
var tag = reply_person.split(",");
$.each( tag, function( key, single_tag ) {
$('#tos').tagit('createTag', single_tag);
});
});
Upvotes: 1