jQuery Modal Window to Display a Table in MVC

放肆的年华 提交于 2019-12-01 13:39:43

First of all, you will need a DIV somewhere on your page - let say give it an id "PopUpPanel". Now create a "ready" event for jQuery to initialize the pop-up/modal dialog:

<script type="text/javascript">
    $(document).ready(function () {
        $("#PopUpPanel").dialog({
            modal: true,
            autoOpen: false,
            height: 'auto',
            width: 'auto',
            buttons: {
                "Close": function () {
                    $(this).dialog("close");
                }
            }
        });
    });
</script>

Assuming the row has a link "Show Detail" - Create a "handler" for "Show Detail" click:

<script type="text/javascript">
    function showDetail(id) {
        $.get('MyController/MyAction/' + id, function(data) {
            $('#PopUpPanel').html(data);
            $('#PopUpPanel').dialog('open');
        });
    }
</script>

Those should get you to the point where your detail page is showing up in a pop-up/dialog window. To pop-up the other form in additional to the detail dialog or to replace the detail dialog, it should be pretty similar.

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