disable jQuery autocomplete dropdown

假装没事ソ 提交于 2019-12-01 10:28:55

问题


This is rather a simple question, but how do I disable the dropdown of the jQuery Autocomplete? When a user starts typing, I run my own function on the response callback. I don't need anything else to appear. This is what I have:

            $( "#search" ).autocomplete({
                source: "/app/friends",
                minLength: 2,
                response: function( event, ui ) {
                    $(".ui-menu-item").hide(); //i hoped this would work
                    display(ui.content);
                }
            });

回答1:


According to the documentation for the plugin, there is an open event that fires when the menu opens. You can put some code in that event to hide the drop down:

$( "#search" ).autocomplete({
    source: "/app/friends",
    minLength: 2,
    response: function( event, ui ) {
        display(ui.content);
    },
    open: function( event, ui ) {
        $(".ui-autocomplete").hide();
    }
});


来源:https://stackoverflow.com/questions/20735013/disable-jquery-autocomplete-dropdown

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