gpt4 book ai didi

javascript - 无法使用/xoxco/jQuery-Tags-Input 显示标签。*

转载 作者:行者123 更新时间:2023-11-28 05:45:10 25 4
gpt4 key购买 nike

我正在尝试让tagsinput插件在一个文本区域中工作,该文本区域位于由jquery对话框插件调用加载的div内。

使用的插件是/xoxco/jQuery-Tags-Input。

我初步检查了 textarea 元素是否已准备好。这是在被调用之前的一段时间。

tagsinput 插件不会将文本区域显示为标签。但是,当我在浏览器中的 firebug 中尝试相同的操作时:

 $('#textarea').importTags('guava','cherry'); // this works

代码如下:

jsp文件:

<div id="mydialog">
<textarea name="tags" id="textareaId">
</div>

JavaScript 文件:

$(document).ready(function(){

$("#mydialog").dialog({
modal: true,
draggable: false,
resizable: false,
position: ['center', 'top'],
show: 'blind',
hide: 'blind',
width: 400,
dialogClass: 'ui-dialog-osx',
buttons: {
"YES": function() {
$(this).dialog("close");
}
}
});

$('#textarea').tagsInput({
'autocomplete_url': '',
'autocomplete': {
source: ['apple','banana'],
autofill:true
},
'height':'100px',
'width':'300px',
'interactive':true,
'defaultText':'add a tag',
});
$('#textarea').importTags('guava','cherry');
});

有什么帮助吗?

最佳答案

在调用 taginput 之前,$('#textarea') 尚未在文档中准备好。我延迟了对 taginput 的调用,它工作正常。

关于javascript - 无法使用/xoxco/jQuery-Tags-Input 显示标签。*,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38587328/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com