bootstrap:modal & iframe

form提交绑定到特定的iframe & form的结果在dialog上显示

 

form:target属性

1
2
3
4
5
<!-- when the form is submitted, the server response will appear in this iframe -->
<form asp-controller="****" asp-action="****" method="post" id="batchClose" target="my_iframe">
    <input id="param1" type="text" name="param1" style="display:none">
    <input id="param2" type="text" name="param2" style="display:none">
</form>

  

modal显示iframe

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<div id="BatchCloseAccountM" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">确认账单</h5>
            </div>
            <div class="modal-body">
                <iframe class="my_iframe" name="my_iframe" src="" frameborder="0" scrolling="no" style="height:110px;width:400px"></iframe>
            </div>
            <div class="modal-footer">
                <button name="cancel" type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>

  

绑定js事件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<script type="text/javascript">
        function BatchClose_method() {
            iframe_init();
            $("#parm1").val(2);
            $("#parm2").val(201902);
            $("#batchClose").submit();
            $("#BatchCloseAccountM").modal('show');
        }
        function iframe_init() {
            $(".my_iframe").contents().find("body").html('<span style="font-size:12px;">加载中。。。 </span>');
        }
        jQuery(function ($) {
            $("#BatchCloseAccountM").on("hidden.bs.modal", function () {
                alert("页面刷新");
            });
        });
    </script>

  

触发modal

1
<a ww-check-acl="~/****/****" href="javascript:void(0);" onclick="BatchClose_method()">确认账单</a>

  

 

posted @   PanPan003  阅读(984)  评论(0编辑  收藏  举报
编辑推荐:
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· 没有源码,如何修改代码逻辑?
· NetPad:一个.NET开源、跨平台的C#编辑器
· 面试官:你是如何进行SQL调优的?
历史上的今天:
2018-04-09 Docker run 出现问题如何调试?
2018-04-09 Docker save & load
点击右上角即可分享
微信分享提示