jQuery UI custom AutoComplete - `_renderItem` and `_renderMenu` not working

泪湿孤枕 提交于 2019-12-04 10:46:34

i've never used extensions in that way, and i can't say why it isn't working (it should, i suppose).

Anyway, try with the standard way, on create callback:

this.input = $("<input>")
    .appendTo(this.wrapper)
    .val(value)
    .attr("title", "")
    .addClass("custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left")
    .autocomplete({
        autoFocus: true,
        response: function (event, ui) {
            if (ui.content.length == 0) {
                    ui.content.push({
                        label: "new value: " + $(this).val(),
                        value: $(this).val(),
                        id: 0
                    });
            }
        },
        delay: 0,
        minLength: 0,
        source: $.proxy(this, "_source"),
        create: function() {
            $(this).data('ui-autocomplete')._renderItem  = function (ul, item) {
              return $("<li>")
                .addClass("Please work")
                .attr("data-value", item.value)
                .append(item.label)
                .appendTo(ul);
            };

        }
    })
    .tooltip({
        tooltipClass: "ui-state-highlight"
    });

see this FIDDLE

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!