jQuery UI Autocomplete Combobox Very Slow With Large Select Lists

前端 未结 5 1310
清歌不尽
清歌不尽 2020-12-04 05:45

I\'m using a modified version of the jQuery UI Autocomplete Combobox, as seen here: http://jqueryui.com/demos/autocomplete/#combobox

For the sake of this questio

5条回答
  •  眼角桃花
    2020-12-04 06:21

    What I have done I am sharing:

    In the _renderMenu, I've written this:

    var isFullMenuAvl = false;
        _renderMenu: function (ul, items) {
                            if (requestedTerm == "**" && !isFullMenuAvl) {
                                var that = this;
                                $.each(items, function (index, item) {
                                    that._renderItemData(ul, item);
                                });
                                fullMenu = $(ul).clone(true, true);
                                isFullMenuAvl = true;
                            }
                            else if (requestedTerm == "**") {
                                $(ul).append($(fullMenu[0].childNodes).clone(true, true));
                            }
                            else {
                                var that = this;
                                $.each(items, function (index, item) {
                                    that._renderItemData(ul, item);
                                });
                            }
                        }
    

    This is mainly for server side request serving. But it can used for local data. We are storing requestedTerm and checking if it matches with ** which means full menu search is going on. You can replace "**" with "" if you are searching full menu with "no search string". Please reach me for any type of queries. It improves performance in my case for at least 50%.

提交回复
热议问题