我有一些文件:如何具有可重复使用jQuery的形式模式
* vehicule_parc.php:*
<script language=javascript src="../js/vehicule_parc.js"></script>
<h3 class="headInfoBox" id="cch">Conso Carburant >></h3>
<hr />
<div id="cc">
<table cellpadding="0" cellspacing="0" border="0" class="display boxtable" id="consoTable">
<thead>
<tr>
<th>Date</th>
<th>Heure</th>
<th>Quantité</th>
<th>Coût</th>
<th>Carte</th>
</tr>
</thead>
<tbody>
<tr class="odd gradeA">
<td>21/03/2011</td>
<td>10:00</td>
<td>30</td>
<td>40</td>
<td>02248</td>
</tr>
...
</div><!-- cc -->
<button id="addcc">Ajouter</button>
<?php include 'form_conso_carb.html'; ?>
* form_conso_carb.html:*
<div id="form_conso_carb" title="Nouvelle Consommation">
<form>
<label for="date">Date</label> <input type="text" name="date" value="" />
<label for="heure">Heure</label> <input type="text" name="heure" value="" />
<label for="quantite">Heure</label> <input type="text" name="quantite" value="" />
<label for="cout">Coût</label> <input type="text" name="cout" value="" />
<label for="carte">Carte</label> <input type="text" name="carte" value="" />
</form>
</div>
* vehicule_parc.js :*
//some code before
J("#form_conso_carb").dialog({
autoOpen : false,
height : 'auto',
width : 300,
modal : true,
position : 'middle',
Cancel : function() {
J(this).dialog("close");
},
buttons : {
"Envoyer" : function() {
}
}
});
J("#addcc")
.button()
.click(function() {
J("#form_conso_carb").dialog("open");
});
//some code after
所以我会哈哈请将您在vehicule_parc.js
中看到的代码保存在可重复使用的文件中。但问题是代码必须知道表的id(这里是id="consoTable"
),以表示ajax。 为什么不,在form_conso_carb.html也在同一个文件。
目标是简单地将无模式表单添加到CRUD a consoTable
。
我希望我能理解。
不工作,J(“#布拉布拉”)对话()必须在页面开始加载,否则'form_conso_carb.html'中所示'vehicule_parc.php' – canardman 2011-03-09 14:14:51
对不起,我很困惑。我想我误解了你需要做的事情。我仍然不确定。 – 2011-03-09 14:19:44
在我想要的地方添加'J(ID).dialog()',并在当前页面上使用与表ID相对应的预定义ID – canardman 2011-03-09 14:59:21