【发布时间】:2015-04-09 08:02:29
【问题描述】:
我正在使用 Bootstrap 和 DataTables/Editor。
在 Google Chrome 中,表格可以在普通的 Bootstrap 容器中呈现,并且具有 Bootstrap 样式,但在 Internet Explorer 中,表格呈现为全宽并且没有 Bootstrap 样式。
我使用 Bootstrap 已经有一段时间了,但在使用它时我从未在浏览器中看到这些不一致,所以我的代码中肯定有一些东西破坏了 Internet Explorer - 但我不知道是什么。
代码如下:
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Editor</title>
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/tabletools/2.2.3/css/dataTables.tableTools.css">
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/plug-ins/3cfcc339e89/integration/bootstrap/3/dataTables.bootstrap.css">
<link rel="stylesheet" type="text/css" href="//editor.datatables.net/examples/resources/bootstrap/editor.bootstrap.css">
<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" language="javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script type="text/javascript" language="javascript" src="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="//cdn.datatables.net/tabletools/2.2.3/js/dataTables.tableTools.min.js"></script>
<script type="text/javascript" language="javascript" src="js/dataTables.editor.min.js"></script>
<script type="text/javascript" language="javascript" src="//cdn.datatables.net/plug-ins/3cfcc339e89/integration/bootstrap/3/dataTables.bootstrap.js"></script>
<script type="text/javascript" language="javascript" src="//editor.datatables.net/examples/resources/bootstrap/editor.bootstrap.js"></script>
<script type="text/javascript" class="init">
var editor; // use a global for the submit and return data rendering in the examples
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
ajax: "php/table.php",
table: "#table",
fields: [
{
"label": "column1",
"name": "column1",
"type": "text"
},
{
"label": "column2",
"name": "column2",
"type": "text"
},
{
"label": "column3",
"name": "column3",
"type": "text"
},
{
"label": "column4",
"name": "column4",
"type": "text"
},
{
"label": "column5",
"name": "column5",
"type": "text"
},
{
"label": "column6",
"name": "column6",
"type": "column6"
},
{
"label": "column7",
"name": "column7",
"type": "text"
},
{
"label": "column8",
"name": "column8",
"type": "text"
}
]
} );
var table = $('#table').DataTable( {
lengthChange: false,
ajax: "php/table.php",
columns: [
{
"data": "column1"
},
{
"data": "column2"
},
{
"data": "column3"
},
{
"data": "column4"
},
{
"data": "column5"
},
{
"data": "column6"
},
{
"data": "column7"
},
{
"data": "column8"
},
{
"data": "column9"
}
]
} );
var tableTools = new $.fn.dataTable.TableTools( table, {
sRowSelect: "os",
aButtons: [
{ sExtends: "editor_create", editor: editor },
{ sExtends: "editor_edit", editor: editor },
{ sExtends: "editor_remove", editor: editor }
]
} );
$( tableTools.fnContainer() ).appendTo( '#table_wrapper .col-sm-6:eq(0)' );
} );
</script>
</head>
<body>
<div class="container">
<h1>
Editor
</h1>
<table class="table table-bordered" id="table">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<th>Column 4</th>
<th>Column 5</th>
<th>Column 6</th>
<th>Column 7</th>
<th>Column 8</th>
<th>Column 9</th>
</tr>
</thead>
</table>
</div>
</body>
</html>
【问题讨论】:
-
哪个版本的 IE 出现问题?
-
您是否看到任何控制台错误?
-
@Izzy 我在 Internet Explorer 11 上遇到了问题,但早期版本也有问题。
-
@DavidG Console 显示“附加页面针对文档模式 7。某些控制台 API 和功能可能不可用。这就是全部。其他标签看起来正常。
-
IE 是否在兼容模式下运行?
标签: jquery css twitter-bootstrap jquery-datatables jquery-datatables-editor