【发布时间】:2012-03-30 23:10:18
【问题描述】:
我尝试为我的项目制作模板,重要的是我需要将几个 php 文件合并为一个。但我有问题,当我将其显示为模态时,一切看起来都很混乱。甚至某些功能和脚本也不起作用。有什么可以帮助或提供最佳解决方案的吗?...非常感谢任何答案。
这是我脚本的一部分...
<div class="section">
<div class="box">
<div class="title">Test</div>
<div class="content">
<div id="load_table"></div>
// table, add button, edit and delete all is here
// When i click edit i want show it as modal and i made a template on other files
// but everithing get mess... any clue to solve my problem ?
<button id="edit" class="green" type="button"><span>Edit</span></button>
<script>
$("#edit").click(function(){
try {
var img_load = "<img src='images/pirobox/loadinfo2.gif' alt='Loading...' />";
$("#load_modal").html(img_load).load("template/edit_form_A.php?uid=123");
// I put parameter cuz i made some function on that file.
} catch(e){ alert(e.message); }
});
$(document).ready(function(){
// DATATABLE
// ...
execute("load_table","template/table_A.php?show=all");
function execute(action,parameter){
if (action!=null) {
switch(action) {
case "load_table":
var img_load = "<img src='images/pirobox/loadinfo2.gif' alt='Loading...' />";
$("#load_table").html(img_load).load( parameter );
break;
case "edit_result": // Callback after modal closed
if ( parameter ) {
execute("load_table",parameter );
}
break;
default
// ...
}
}
}
}
</script>
</div>
</div>
【问题讨论】:
-
你用过PHP的include()函数吗?
-
在我分离的文件上?...我认为不是。我只是把它放在我的主文件中。像 index.php 或 header.php。如果我不使用 modal 或 ajax,该模板正在工作。我很困惑...@_@!
-
当您说 modal 时,您是在说 LightBox 之类的东西吗?
-
删除您可能在 template/edit_form_A.php 和 template/table_A.php 上拥有的任何
<script>标签。 -
@cilosis 是的...我正在使用 pirobox。