我有一个页面,在面板主体内有几个表格。其中一个表,在行div和面板div中,我想在用户生成然后解除模态后重新加载。我的代码有效,但重新加载表it gets squashed like so。
是否无法在面板主体中重新加载表?
编辑:该表首先包含在底部,如下所示:
<div class="row">
<!-- Sales by Month -->
<div class="col-md-4">
<h3 class="text-center">Sales By Month</h3>
<table class="table table-bordered table-striped table-condensed">
<thead><th></th><th><?=$last_year;?></th><th><?=$this_year;?></th></thead>
<tbody>
<?php for ($i = 1; $i <= 12; $i++):
$dt = DateTime::createFromFormat('!m',$i);
$t = $this_array[$i]?? 0;
$l = $last_array[$i]?? 0;
$this_total += $t;
$last_total += $l;
?>
<tr>
<td><?=$dt->format("F");?></td>
<td><?=money($l);?></td>
<td><?=money($t);?></td>
</tr>
<?php endfor ;?>
<tr>
<td style="font-weight:bold" class="text-center">Year Total:</strong><td><?=money($last_total);?></td><td><?=money($this_total);?></td>
</tr>
</tbody>
</table>
</div>
<!-- Low Inventory -->
<?php include 'low_inventory.php'; ?>
</div>
</div> <<<<<< this div closes the whole panel
页面本身如下所示:
<div id="low-inventory" class="col-md-8">
<?php
require_once 'core/init.php';
$low_inventory = $db->query("SELECT a.stock, a.id AS 'stock_id', a.product_id, a.threshold, b.title, c.size FROM stock a JOIN products b ON a.product_id = b.id
JOIN sizes c ON a.size = c.id WHERE (stock < 5 AND threshold = 0) OR (stock < threshold AND threshold > 0) ORDER BY stock ASC");
?>
<h3 class="text-center">Low Inventory</h3>
<table class="table table-bordered table-striped table-condensed table-hover table-hand-pointer">
<thead class="noninteractive"><th>Product</th><th>Size</th><th>Stock</th><th>Stock ID</th><th>Threshold</th></thead>
<tbody>
<?php while($low = mysqli_fetch_assoc($low_inventory)): ?>
<tr <?=empty($low['stock'])? 'class="danger" ':'';?> onclick=show_stock(<?=$low['product_id'];?>)>
<td><?=$low['title'];?></td>
<td><?=$low['size'];?></td>
<td><?=$low['stock'];?></td>
<td><?=$low['stock_id'];?></td>
<td><?=$low['threshold'];?></td>
</tr>
<?php endwhile ;?>
</tbody>
</table>
</div>
由此重新加载:
$("#low-inventory").load("<?=ADMINURL;?>low_inventory.php");
答案 0 :(得分:1)
将<div id="low-inventory" class="col-md-8">
放在low_inventory.php
之外:
<div id="low-inventory" class="col-md-8">
<?php include 'low_inventory.php'; ?>
</div>
否则重新加载后你会被双重包裹:
<div id="low-inventory" class="col-md-8">
<div id="low-inventory" class="col-md-8">
...