Javascript 如果使用.Load()加载内容,则在模态onSubmit中加载内容
我们目前正在将内容加载到Twitter引导模式框中的Javascript 如果使用.Load()加载内容,则在模态onSubmit中加载内容,javascript,jquery,twitter-bootstrap,joomla,joomla2.5,Javascript,Jquery,Twitter Bootstrap,Joomla,Joomla2.5,我们目前正在将内容加载到Twitter引导模式框中的iframe。但是,由于我们加载内容时使用了Joomla的仅内容后缀:?tmpl=component,因此无法执行样式 <?php echo '… $("a[data-toggle=\'"+$modalText+"\']").on(\'click\', function (e) { // Call the modal manually var url = $(this).attr(\'href\'); $modal
iframe
。但是,由于我们加载内容时使用了Joomla的仅内容后缀:?tmpl=component
,因此无法执行样式
<?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");
});
…';?>
如果希望“在模式内提交”,则应阻止默认表单提交(这将触发整个页面加载),并改为发送ajax请求
您可以手动执行此操作,或者使用jQuery表单插件(您可以找到它)并调用.ajaxForm()
:
您还可以编辑模板目录中的component.php以包含CSS文件。这样可以避免在jQuery中编写任何代码;)
//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
});