form提交绑定到特定的iframe & form的结果在dialog上显示
form:target属性
<!-- 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
<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事件
<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
<a ww-check-acl="~/****/****" href="javascript:void(0);" onclick="BatchClose_method()">确认账单</a>
原文地址:https://www.cnblogs.com/panpanwelcome/p/10678638.html
时间: 2024-11-10 02:25:00