【问题标题】:select2 is not showing when the map is fullscreen地图全屏时 select2 不显示
【发布时间】:2020-01-19 03:44:32
【问题描述】:

嘿,我试图在谷歌地图上显示 select2(它的后端),但当地图全屏时,列表没有显示。我尝试通过更改 z-index 值但不工作。可以有人帮帮我吗??

    $('document').ready(function() {
    $('#Name').select2({
        placeholder: "Choose name",
        minimumInputLength: 3,
        ajax: {
            url: 'somthing here ...',
            dataType: 'json',
            data: function (params) {
                return {
                    q: $.trim(params.term)
                };
            },
            processResults: function (data) {
                // console.log(data);
                return {
                    results: data
                };
            },
            cache: true
        }
    });
   });

【问题讨论】:

    标签: javascript jquery google-maps jquery-select2


    【解决方案1】:

    现在您的 select2 div 位于 body 的所有 div 最后一个元素之外。

    dropdownParent 传递给 google 地图类,以便 select2 div 将在该 div 中。

    检查检查元素,然后尝试使用 z-index。

     $('#Name').select2({
            placeholder: "Choose name",
            minimumInputLength: 3,
            dropdownParent: $('.map'),
            ajax: {
                url: 'somthing here ...',
                dataType: 'json',
                data: function (params) {
                    return {
                        q: $.trim(params.term)
                    };
                },
                processResults: function (data) {
                    // console.log(data);
                    return {
                        results: data
                    };
                },
                cache: true
            }
        });
    

    查看更多信息:common-problems

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-15
      • 2019-09-06
      • 1970-01-01
      • 2010-12-16
      相关资源
      最近更新 更多