【发布时间】:2015-07-28 11:34:29
【问题描述】:
我目前正在使用以下库: Bootstrap Tags
用户界面运行良好。 但是我对如何检索输入框中的所有值感到困惑? (我想要用户输入的整个标签列表)并将该信息发送到服务器端。 (首先我想使用 javascript 打印出来,然后使用 post 请求发送到服务器)
$("input").val()
$("input").tagsinput('items') //this is giving me error message
这是我的代码:
<!-- Textarea -->
<div class="form-group">
<label class="col-md-3 control-label" for="textarea">Search Tags</label>
<div class="col-md-8">
<input class="form-control" id="tagTextarea" data-role="tagsinput" id="tagsInput" />
</div>
</div>
<script>
$('input').tagsinput({
trimValue: true
}
);
$('input').on('beforeItemAdd', function(event) {
// event.item: contains the item
// event.cancel: set to true to prevent the item getting added
//Now how do i retrieve those values inside?
console.log(tags);//<--how to print value?
});
</script>
【问题讨论】:
-
没有这样的功能:$("input").tagsinput
-
我们需要看到更多的分配来调试它。请包含一个链接或您的完整 HTML 页面。我认为这与在执行该代码或根本不包含该代码之后包含的 tagsinput 插件有关。
-
在表单提交时,我如何获取用户输入的内容? (在我包含 taginput 输入字段之后)
标签: javascript php twitter-bootstrap