繁体   English   中英

Bootstrap-加载位于其他页面的模式,并从模式提交表单

[英]Bootstrap - Load modal residing in other page and form submission from modal

1.我有一个页面,单击按钮会弹出模态。 我想做的就是将所有模型移到单独的页面。 我已经试过了

    $('#newSection').click(function(){
        $('#temp').load('adminmodels.php');
        $('#newSectionModal').modal('show');
    });

第一次单击时,没有任何反应。 在随后的单击中,模态会出现并自动消失。 请提出建议并修改我的代码。

2.我想从模态内部提交一个表格,然后在模态本身中显示响应。

    $(document).ready(function(){
        $('#user_button').click(function(e){
            e.preventDefault();
            $(this).attr('disabled',true);
            $.post('__admin_ajax.php',postString,function(response){
                $('#user-modal-body').html(response);
            });
        });
    });

先前提交的表单的响应保留给后续的模态加载。

对于这种逻辑,我发现仅使用iframe会更容易。

<div id="newSectionModal">
  <iframe id="modal_frame"/>
<div>

然后在代码中。

$('#newSection').click(function(){
    $('#modal_frame').attr('src', 'adminmodels.php');
    $('#newSectionModal').modal('show');
});

因为它在框架中,所以您可以像在自己的窗口中一样处理表单提交。 您可以随时通过调用window.parent来触发父框架。 例如:window.parent.trigger(“提交表单”)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM