简体   繁体   English

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

[英]Not able to show tags using /xoxco/jQuery-Tags-Input.*

I am trying the tagsinput plugin to work in a textarea which is inside a div that is loaded by the jquery dialog plugin call. 我正在尝试tagsinput插件在jQuery对话框插件调用加载的div内的textarea中工作。

Plugin used is the /xoxco/jQuery-Tags-Input. 使用的插件是/ xoxco / jQuery-Tags-Input。

I did an initial check if the textarea element is ready. 我做了初步检查是否textarea元素准备好了。 It is while before being called. 是在被叫之前。

The textarea doesn't get displayed as tags by the tagsinput plugin. 标签输入插件不会将textarea显示为标签。 However when I try the same from firebug in the browser: 但是,当我尝试从浏览器中的萤火虫尝试相同操作时:

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

Code below: 代码如下:

jsp file: jsp文件:

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

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

Any help why? 有什么帮助吗?

$('#textarea') was not yet ready in the document before the tagsinput was called. 在调用标签输入之前,$('#textarea')在文档中尚未准备好。 I delayed my invocation for tagsinput and it worked Ok. 我延迟了对tagsinput的调用,效果很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM