weixin_33736649 2018-12-06 04:52 采纳率: 0%
浏览 24

小部件z-index修改

I am having issue in displaying a widget inside a modal on ASP.NET MVC platform. Currently, the widget is showing at the back of my modal.

@Html.TextBoxFor(Function(model) model.Clinic, New With {.Style = "width:300px", .id = "txtClinic"})

Widget

$.widget('custom.mcautocomplete', $.ui.autocomplete, {
    _create: function () {
        this._super();
        this.widget().menu("option", "items", "> :not(.ui-widget-header)");
    },
    _renderMenu: function (ul, items) {
        var self = this,
            thead;
        if (this.options.showHeader) {
            table = $('<div class="ui-widget-header" style="width:100%"></div>');
            $.each(this.options.columns, function (index, item) {
                table.append('<span style="padding:0 4px;float:left;width:' + item.width + ';">' + item.name + '</span>');
            });
            table.append('<div style="clear: both;"></div>');
            ul.append(table);
        }
        $.each(items, function (index, item) {
            self._renderItem(ul, item);
        });
    },
    _renderItem: function (ul, item) {
        var t = '',
            result = '';
        var term = this.term;
        $.each(this.options.columns, function (index, column) {
            var value = item[column.valueField ? column.valueField : index];
            t += '<span style="padding:0px 4px;float:left;width:' + column.width + ';height:13px;">' + value + '</span>'
        });

        var $a = '<a class="mcacAnchor">' + t + '<div style="clear: both;"></div></a>';

        result = $('<li style="border-bottom: solid 1px #cccccc"></li>')
            .data('ui-autocomplete-item', item)
            .append($a)
            .appendTo(ul);

        return result;
    }
});

Ajax

$("#txtClinic").mcautocomplete({

    showHeader: true,
    columns: [{
        name: 'Code',
        width: '120px',
        valueField: 'ClinicCode'
    }, {
        name: 'Clinic Name',
        width: '370px',
        valueField: 'Clinic'
    }
    ],

    minLength: 3,
    source: function (request, response) {
        $.ajax({
            cache: false,
            url: '/User/GetClinicAllDetails',
            type: "POST",
            dataType: "json",
            data: { query: request.term },
            success: function (data) {
                response($.map(data, function (item) {
                    return {
                        ClinicCode: item.ClinicCode,
                        Clinic: item.Clinic
                    }
                }));
            },
            error: function (response) {
                swal("", response.message, "error");
            }
        });
    }
});

All the codes are listed in my Modal View, any ideas what could went wrong?

  • 写回答

1条回答 默认 最新

  • weixin_33725270 2018-12-07 00:53
    关注

    For anyone who is having the same issue as me.

    Simply add the following line to the widget portion:

    $(".ui-autocomplete.ui-front.ui-menu.ui-widget.ui-widget-content").addClass("zindex9999");
    

    In your style:

    .zindex9999{z-index:9999 !important;}
    

    The reason of doing so is because when a modal is opened, the position is set to absolute and it neglect all the existing div, by setting z-index to 9999, it actually overwrites the absolute index as the absolute index is around 9998 (I'm not sure)

    评论

报告相同问题?

悬赏问题

  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
  • ¥15 下列c语言代码为何输出了多余的空格