- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下 javascript,它会触发 colorbox 使用服务器上的参数打开特定的 PHP 页面:
$(document).ready(function() {
$('#example tbody').on( 'click', 'input', function () {
var data = table.row( $(this).parents('tr') ).data();
$(".iframe").colorbox({iframe:true, width:"700px", height:"80%", href:"session_edit.php?ID="+data[0]});
$(".iframe2").colorbox({iframe:true, width:"700px", height:"80%", href:"index_b.html?ID="+data[0]});
$(".iframe3").colorbox({iframe:true, width:"300px", height:"20%", href:"delete.php?ID="+data[0], onLoad: function() {
$('#cboxClose').remove()
}});
});
});
不,我想使用 Bootstrap 模式而不是 colorbox。我尝试过:
$("#iframe").modal('show');
但是它不起作用,也不知道如何用 ?ID= 指定 PHP 文件
知道如何解决这个问题吗?
谢谢
最佳答案
您的问题有点不清楚什么不起作用,但我认为您正在尝试将远程 php 文件加载到 Bootstrap 模式中,该文件不像颜色框中那样显示,并且希望用 Bootstrap 模式替换颜色框
您可以在 Bootstrap 模式调用按钮 href="session_edit.php?ID=<?php echo $id;?>">
中添加这样的远程文件并使用 ?ID=
<button class="btn btn-primary" data-toggle="modal" data-target="#iframe" href="session_edit.php?ID=<?php echo $id;?>">Open Modal</button>
您不需要 jQuery 来调用模态,让 bootstrap 默认模态功能完成它的工作
要触发模态窗口,您需要包含两个 data-* 属性:
data-toggle="modal" //opens the modal window
data-target="#iframe" //points to the id of the modal
所以你不需要这个 jQuery 代码来显示 Bootstrap 模式
$("#iframe").modal('show');
模态 HTML 将是
<div class="modal fade" id="iframe" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
//Content loads here
</div>
</div>
</div>
同样在远程 php 文件中您可以添加 moda-header
, modal-body
和modal-footer
远程 php session_edit.php
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title"><center>Heading</center></h4>
</div>
<div class="modal-body">
//Show what ever content here you like it will load into the modal
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default">Submit</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
最后,如果您在同一页面上处理多个模态而不刷新页面,则可能需要刷新模态内容
<script>
$( document ).ready(function() {
$('#iframe').on('hidden.bs.modal', function () {
$(this).removeData('bs.modal');
});
});
</script>
希望这有帮助。
关于javascript - 使用 Bootstrap 模态代替 Colorbox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32646170/
我来自 Asp.Net 世界,试图理解 Angular State 的含义。 什么是 Angular 状态?它类似于Asp.Net中的ascx组件吗?是子页面吗?它类似于工作流程状态吗? 我听到很多人
我一直在寻找 3 态拨动开关,但运气不佳。 基本上我需要一个具有以下状态的开关: |开 |不适用 |关 | slider 默认从中间开始,一旦用户向左或向右滑动,就无法回到N/A(未回答)状态。 有人
我是一名优秀的程序员,十分优秀!