【问题标题】:Open Jquery-UI Dialog Box inside table not showing in right place?打开表格内的 Jquery-UI 对话框没有显示在正确的位置?
【发布时间】:2021-01-15 18:40:01
【问题描述】:

这是动态显示对话框的 jQuery 代码。

function ShowDialog(id) {

        var x = $('btn_' + id).position();

        $("#dialog_" + id).dialog({
            title: "Description",
            position:{ my:"" },
            autoOpen: false,
            show: {
                effect: "blind",
                duration: 1000
            },
            hide: {
                effect: "explode",
                duration: 1000
            },
            position:
                 { my: "center", at: "center", of: window }
        });

        var theDialog = $("#dialog_" + id);
        theDialog.dialog("open");

    }

这里是动态生成的网格视图的 Html 代码。

<asp:TemplateField HeaderText="Description" ItemStyle-Width="80px">
                <ItemTemplate>
                    
                    <div id="dialog_1" style="display: none;">
                        <p>Details</p>
                    </div>

                    <button type="button" class="btn btn-success btn-sm btn_1" onclick="ShowDialog(1)">Show Detail</button>
                </ItemTemplate>
            </asp:TemplateField>

输出是:

应该在这里营业

【问题讨论】:

  • 不确定你在哪里使用x,但你在var x = $('btn_' + id).position();的选择器中缺少.#
  • Ok它的类那么怎么计算呢?
  • 如果是班级使用$('.btn_' + id)
  • 现在告诉我如何使用 x 值计算位置

标签: c# jquery asp.net twitter-bootstrap webforms


【解决方案1】:

尝试像这样写position: { my: "right center", at: "right center"}

function ShowDialog(id) {

        var x = $('btn_' + id).position();

        $("#dialog_" + id).dialog({
            title: "Description",
            position:{ my:"" },
            autoOpen: false,
            show: {
                effect: "blind",
                duration: 1000
            },
            hide: {
                effect: "explode",
                duration: 1000
            },
            position:
                 { my: "right center", at: "right center", of: window }  // here
        });

        var theDialog = $("#dialog_" + id);
        theDialog.dialog("open");

    }

【讨论】:

  • 它不工作,而不是在其左侧显示 0px 的 CSS 样式显示。建议我使用 jQuery 计算左侧像素并设置到位置?
猜你喜欢
  • 1970-01-01
  • 2013-10-30
  • 2012-08-24
  • 2014-08-22
  • 1970-01-01
  • 2012-07-16
  • 1970-01-01
  • 2012-12-04
  • 1970-01-01
相关资源
最近更新 更多