小编azt*_*tuk的帖子

jquery autocomplete使mCustomScrollbar在select上滚动到顶部

我在后台接口中实现了mCustomScrollbar插件.它工作正常.但在我的一个表单中,我有一个需要自动完成的城市字段.

自动完成也很好.但是当我从自动完成源数据中选择一个项目时,mCustomScrollbar插件会自动将我带到滚动内容的顶部,我必须再次单击以实际选择该项目.

这是我实现滚动条插件的方式:

$('#mainContent').mCustomScrollbar({
        set_height: height,
        scrollInertia: 500,
        scrollEasing: "easeInOutQuad",
        mouseWheel: 20,
        autoDraggerLength: true,
        advanced: {
            updateOnBrowserResize: true,
            updateOnContentResize: false
        }
    });
Run Code Online (Sandbox Code Playgroud)

这就是我实现自动完成的方式:

el.autocomplete({
    source: function (request, response) {
        $.ajax({
            url: activityAutocomplete,
            dataType: "json",
            data: request,
            success: function (data) {
                if (data.length == 0) {
                    data.push({
                        label: "Pas de résultat"
                    });
                }
                response(data);
            }
        });
    },
    //If overflow edge of window, the autocomplete flips to top of input
    position: { collision: "flip" },
    autofocus: true,
    delay: 150,
    minLength: 1,
    select: …
Run Code Online (Sandbox Code Playgroud)

javascript jquery jquery-ui autocomplete

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

autocomplete ×1

javascript ×1

jquery ×1

jquery-ui ×1