无法使用/xoxco/jQuery-Tags-Input.*

时间:2016-07-26 10:26:50

标签: javascript jquery html jquery-tags-input

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

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

我初步检查了textarea元素是否准备就绪。这是在被召唤之前。

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');
});

任何帮助原因?

1 个答案:

答案 0 :(得分:0)

在调用tagsinput之前,

$(&#39;#textarea&#39;)尚未在文档中准备就绪。我延迟了我对tagsinput的调用,它运行正常。