我有兩個div,我想在那裏加載模板。我試圖加載這樣的, 它不工作。這是我的代碼。在DIV中加載模板
main.htm中
Details
<div id="placeholder1" />
<div id="placeholder2" />
Template1.htm
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#example').dataTable({
"bProcessing": true,
"bPaginate": false,
"sAjaxSource": '/Home/GetReport1',
});
});
</script>
</head>
TESTING.........
<div id="dynamic">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
<thead>
<tr>
<th width="20%">Date</th>
<th width="25%">Time</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</html>
Template2.htm
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#example').dataTable({
"bProcessing": true,
"bPaginate": false,
"sAjaxSource": '/Home/GetReport1',
});
});
</script>
</head>
TESTING.........
<div id="dynamic">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
<thead>
<tr>
<th width="20%">Place</th>
<th width="25%">Food</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</html>
在這裏,我如何加載模板形式JS文件
myjs .js
var placeholder = $("#tab");
placeholder.setTemplateURL("/Templates/Home/main.htm");
placeholder.load("/Templates/Home/pricinghistory.htm");
var firstDiv = $("placeholder1");
firstDiv.setTemplate("/Templates/Home/Template1.htm");
firstDiv.load("/Templates/Home/Template1.htm");
Darin,謝謝你的回覆。是的,我將它們加載到site.master文件中。但至少它應該顯示「測試....字符串」對不對?它甚至沒有顯示,也 – Naruto
我想你正在得到我想說的,我不想要網格。但至少測試字符串應該是吶,它甚至沒有出現 – Naruto
然後我想你有加載模板的問題。檢查你的javascript控制檯,檢查FireBug中的AJAX請求,看看它爲什麼失敗。 –