jQuery标签编辑器功能

发布于 2024-09-03 03:14:39 字数 1159 浏览 1 评论 0原文

我正在使用 jQuery 标签编辑器 (http://blog.crazybeavers .se/wp-content/demos/jquery.tag.editor/)用于学校项目。一切都很完美,但我无法检索我添加的标签数组。这是我的代码:

$("#allTags").click(function () {    
    var tags = $("#tagEditor").tagEditor().getTags();    
    alert(tags);
});

数组不返回任何内容。

这是 jQuery 标签编辑器中的代码:

(function ($) {
    $.fn.extend({
        tagEditor: function (options) {
            var defaults = {
                separator: ',',
                items: [],
                className: 'tagEditor',
                confirmRemoval: false,
                confirmRemovalText: 'Do you really want to remove the tag?',
                completeOnSeparator: false,
                completeOnBlur: false,
                initialParse: true
            }

            var options = $.extend(defaults, options);
            var listBase, textBase = this, hiddenText;
            var itemBase = [];

            this.getTags = function () {
                return itemBase.join(options.separator);
            };
...

I'm using jQuery Tag Editor (http://blog.crazybeavers.se/wp-content/demos/jquery.tag.editor/) for a school project. Everything works perfect, but i'm not able to retrieve the array of tags that I added. This is my code:

$("#allTags").click(function () {    
    var tags = $("#tagEditor").tagEditor().getTags();    
    alert(tags);
});

The array doesn't return anything.

This is the code from the jQuery Tag Editor:

(function ($) {
    $.fn.extend({
        tagEditor: function (options) {
            var defaults = {
                separator: ',',
                items: [],
                className: 'tagEditor',
                confirmRemoval: false,
                confirmRemovalText: 'Do you really want to remove the tag?',
                completeOnSeparator: false,
                completeOnBlur: false,
                initialParse: true
            }

            var options = $.extend(defaults, options);
            var listBase, textBase = this, hiddenText;
            var itemBase = [];

            this.getTags = function () {
                return itemBase.join(options.separator);
            };
...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

少跟Wǒ拽 2024-09-10 03:14:39

如果您仍然遇到问题,那么我建议您获取该插件的最新版本(从您上面提到的网站)。 getTags() 方法在最新版本中被重写,现在工作得更好了。

If you still have problems with this then I would recommend that you get the latest version of the plugin (from the site you mentioned above). The getTags()-method was rewritten in the latest version and works much better now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文