bootstrap:modal & iframe

form提交綁定到特定的iframe & form的結果在dialog上顯示javascript

 

form:target屬性html

<!-- 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顯示iframejava

<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事件app

<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>

  

觸發modalpost

<a ww-check-acl="~/****/****" href="javascript:void(0);" onclick="BatchClose_method()">確認帳單</a>
相關文章
相關標籤/搜索