[英]Add tags to tag bar using xoxco tag plugin
I'm trying to add a tag from a list of words by just simply clicking the word and it gets added. 我正在尝试从单词列表中添加标签,只需单击单词即可添加它。 I've tried to add a new value to the input in the HTML but that doesn't add a new tag in. 我尝试将新值添加到HTML的输入中,但是没有在其中添加新标签。
$("li").click(function() {
var word = $(this).text();
var value = $('.tagBar').attr('value');
var newValue = value+","+word;
$('.tagBar').attr('value', newValue);
});
I then tried to use the addTag(value,options) instead but I just kept getting errors. 然后,我尝试使用addTag(value,options)代替,但我一直不断出错。
How do you add a new tag without typing in the box and just clicking? 您如何在不输入框的情况下直接单击添加新标签?
I have a drop down list and a button to let the user add multiple items in a tag list using Xoxco tag input control. 我有一个下拉列表和一个按钮,允许用户使用Xoxco标签输入控件在标签列表中添加多个项目。 This is what I do: 这是我的工作:
$("#btnAgregarMaterial").click(function (e) {
e.preventDefault(); // avoids submitting the form
var control = $("#cbbMateriales"); // gets drop down list
var value = control.data("value"); // gets item value (ID)
if (value > 0) { // if it is an item with ID greater than zero
var text = control.text(); // get item text
var tagsControl = $("#tags"); // gets tags input control
tagsControl.addTag(text); // adds tag using addTag function
}
});
In order to add a tag, you need to use the function addTag. 为了添加标签,您需要使用功能addTag。 Setting the value directly won't work. 直接设置该值无效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.