2013-02-27 32 views
1

1.我是一个页面,点击按钮可以调出模态。我想要做的是将所有模型移至单独的页面。我试过Bootstrap - 载入模态位于其他页面和表单提交模态

$('#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); 
      }); 
     }); 
    }); 

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

回答

0

我发现这种类型的逻辑,使用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(“form-submitted”)