我有一个带有表单的页面,它是通过 AJAX 调用创建的,其中包含一个Bootstrap Tags Input 元素。以下代码尝试利用标准标签输入事件,但没有效果:
Javascript:
<script>
$(document).on('itemAdded itemRemoved', '.bootstrap-tagsinput input', function(e) {
alert('triggered');
// call some function
});
// after the form is generated via the AJAX call, the tags input is 'refreshed'
...
$('.input_tags').tagsinput('refresh');
...
</script>
HTML(这是应用标签输入插件时生成的标准 HTML;'tag...' 元素的添加/删除对应于用户在输入字段中添加/删除标签):
<div class="bootstrap-tagsinput">
<span class="tag label label-info">
...
<span class="tag label label-info">
<input type="text" size="4">
</div>
关于这里可能出现什么问题以及如何解决的任何想法?