【问题标题】:Not able to show tags using /xoxco/jQuery-Tags-Input.*无法使用 /xoxco/jQuery-Tags-Input.* 显示标签
【发布时间】:2016-07-26 10:26:50
【问题描述】:

我正在尝试 tagsinput 插件在由 jquery 对话框插件调用加载的 div 内的 textarea 中工作。

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

我初步检查了 textarea 元素是否准备就绪。在被调用之前是 while。

标签输入插件不会将文本区域显示为标签。但是,当我在浏览器中从 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');
});

有什么帮助吗?

【问题讨论】:

    标签: javascript jquery html jquery-tags-input


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多