【问题标题】:Custom render tag-it plugin自定义渲染 tag-it 插件
【发布时间】:2016-10-26 11:18:47
【问题描述】:

我正在为我的 tag-it 建议创建自定义渲染。 我目前能够使用此代码覆盖退货项目:

$projectTags.tagit({
            autocomplete: ({
                delay: 0,
                minLength: 2,
                source: test,
                select: function (event, ui) {
                    that.createTag(ui.item.value);
                    // Preventing the tag input to be updated with the chosen value.
                    return false;
                }

            })
        });

        $projectTags.find("input").data("uiAutocomplete")._renderItem = function (ul, item) {
            var newItem = $("<li class='project-tagit-li'>");
            var color = $.string_to_color(item.OwnerName);
            var initials = item.OwnerName.split(" ")[0][0] + item.OwnerName.split(" ")[1][0];
            newItem.attr("data-value", item.OwnerId);

            var html = '<p class="initials initials-project-tagit" title="' + item.OwnerName + '" style="background-color:' + color + '" >' + initials + '</p><div><p class="projectName">' + item.Name + '</p><p class="companyName">' + item.CompanyName + '</p></div>';

            newItem.append(html)
            return newItem.appendTo(ul);
        };

问题是,所有由 tag-it 绑定的事件都不适用于我自己的项目。 有人想再次绑定它们吗?

【问题讨论】:

    标签: jquery jquery-ui tag-it


    【解决方案1】:

    我找到了解决方案:

    li 需要有一个&lt;a&gt;,如果你有自定义对象,item.label & value 不应该为空

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-10
      • 2013-07-27
      • 1970-01-01
      • 2019-02-27
      • 1970-01-01
      • 2017-06-09
      相关资源
      最近更新 更多