2013-10-09 61 views
0

我们正在将内容加载到Twitter Bootstrap模式框中的iframe上,则以模式onSubmit加载内容。但是,由于我们使用Joomla的仅限内容的后缀加载内容,所以样式并未通过:?tmpl=component如果内容加载了.load()

<?php echo '… 
$("a[data-toggle=\'"+$modalText+"\']").on(\'click\', function (e) { 
    // Call the modal manually 
    var url = $(this).attr(\'href\'); 
    $modal.find(".modal-body-content").html(\'<iframe frameborder="0" width="100%" height="700" allowtransparency="true" src="\' + url + \'"></iframe >\'); 
    $modal.modal("show"); 
}); 
…';?> 

原因是该内容包含表格&提交按钮。如果我们通过jQuery的​​函数加载内容,有没有办法将内容保留在模态中并在模态中提交?

感谢您的任何建议。

回答

1

如果你想“在模态内部提交”,你应该防止默认表单提交(这将触发整页加载),并发送一个ajax请求。

你可以手工做到这一点,或使用jQuery的形式插件(你可以找到它here)并调用.ajaxForm()

//to be called once, when the form is present in the DOM 
$('#myForm').ajaxForm({ 
    success: function(data){ 
     //code to execute when submit successfully returned from server 
     //the "data" variable contains whatever the answer is : html, json ... 
    } 
    //you define here any option of the "$.ajax()" function 
}); 
0

你也可以在你的模板目录编辑component.php包括一个CSS文件。这样你就可以避免在jQuery中编写任何代码;)

相关问题