Collapse ne fonctionne pas avec une table dynamic
Bonjour,
Mon j'ai un collapse qui fonctionne. Mais lorsque je l'insers dans un TD d'un tableau où j'ajoute dynamiquement mes lignes par des appendChild, ça ne fonctionne plus.
Ci-dessous mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| <table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th width="2"></th>
<th width="80">Ref Article</th>
<th width="20">Désign Article</th>
<th width="5">Unite</th>
<th width="10">Prix Unitaire</th>
<th width="10">Quantité</th>
<th width="5">Remise</th>
<th width="15">Total</th>
</tr>
</thead>
<tbody id="table_article"> </tbody>
</table>
<table>
<tbody>
<tr>
<td>
<div class="form-inline">
<input type="text" class="form-control article_remise">
<img class="sendto" src="../Assets/calculatrice.png" style="width: 40px; height: 40px; cursor: pointer;" >
</div>
<div class="collapse">
<div class="form-group col-md-6 alert alert-info">
<label for="Tel">Element 1:</label>
<input type='text' class='form-control'>
</div>
<div class="form-group col-md-6 alert alert-info">
<label for="Tel">Element 2:</label>
<input type='text' class='form-control'>
</div>
</div>
</td>
<td><input type="number" class="form-control article_total" readonly="readonly"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$(".sendto").click(function(){
$(".collapse").collapse('toggle');
});
});
// AJOUTER UNE LIGNE
$(document).ready(function()
{
var Table_noms_messages = document.getElementById('table_article');
const TR_Base = document.querySelector('#fantome tbody tr');
$('#add_article').click(function () { // "Ajouter un produit"
var new_tr_clone = TR_Base.cloneNode(true);
Table_noms_messages.appendChild( new_tr_clone );
});
}
</script> |
Merci!
La trop méconnue méthode index()
Bonjour,
tiens on pourrait appliquer ici la réponse faite dans cette discussion.