Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/458.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何为加载DOM后添加的输入激活bootstrap.tagsinput?_Javascript_Jquery_Twitter Bootstrap_Tags_Bootstrap Tags Input - Fatal编程技术网

Javascript 如何为加载DOM后添加的输入激活bootstrap.tagsinput?

Javascript 如何为加载DOM后添加的输入激活bootstrap.tagsinput?,javascript,jquery,twitter-bootstrap,tags,bootstrap-tags-input,Javascript,Jquery,Twitter Bootstrap,Tags,Bootstrap Tags Input,我正在动态添加一些我希望成为标记字段的字段 我正在使用 原始文档中任何标有data role=tags的输入结果都很好。但是,如果我使用jQuery添加更多内容 如何将bootstrap.tagsinput应用于它们?我刚才做了: $('#input-tags').tagsinput('destroy'); $('#input-tags').tagsinput(); 无需添加和删除所有标记即可工作。您需要在创建新标记的函数上使用回调来运行Boostrap函数。如果你能展示一些代码,我们可以提供

我正在动态添加一些我希望成为标记字段的字段

我正在使用

原始文档中任何标有data role=tags的输入结果都很好。但是,如果我使用jQuery添加更多内容

如何将bootstrap.tagsinput应用于它们?

我刚才做了:

$('#input-tags').tagsinput('destroy');
$('#input-tags').tagsinput();

无需添加和删除所有标记即可工作。

您需要在创建新标记的函数上使用回调来运行Boostrap函数。如果你能展示一些代码,我们可以提供更多帮助。那么你是说每次我通过用户ineteraction添加一组新字段时,我都应该重新加载整个代码?我会展示代码,但实际上没有比我说的更多的东西了。用户点击按钮->字段出现,除非他们没有得到taggifiedI,我不这么说,因为我不知道你的代码是什么样子。如果需要更多帮助,请显示它。我想您可以使用jQuery选择元素并对其应用.tagsinput方法,或者使用$'[data role=tagsinput]'.tagsinput将其应用于具有数据角色的所有元素。但不确定是否可以将插件应用于同一元素两次。