[英]Bootstrap Tags: how to retrieve items from the input list to server side?
我目前正在使用以下庫: Bootstrap標簽
UI工作得很好。 但我很困惑如何檢索輸入框內的所有值? (我想要用戶輸入的整個標簽列表)並將該信息發送到服務器端。 (首先我想用javascript打印出來然后使用post request發送到服務器)
$("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>
Ypu可以使用jquery的serialize
函數來獲取所有表單值。
$('#formId').serialize();
您可以遍歷該函數提供的結果以在客戶端進行打印,並將相同的結果發送到服務器端代碼。
你可以通過jQuery serialize()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.