Consider the following table which iterates data from an sqlite
database using flask
and sqlalchemy
.
Assume for this example that the data is a list of invoices and clicking on each row opens a collapsible bootstrap accordion
whith further information for the clicked invoice.
<table class="table table-hover" data-toggle="table">
<thead>
<tr>
<th>Date</th>
<th>Invoice</th>
</tr>
</thead>
<tbody>
<tr data-toggle="collapse" data-target="#accordion" class="clickable">
{% for inv in invoices %}
<td>
{{ inv.number }}
</td>
</tr>
<tr>
<td>
<div id="accordion" class="collapse">
{{ inv.data }}
</div>
</td>
</tr>
{% endfor %}
</body>
</table>
The problem here is that only the first row is clickable and clicking on it opens all the rows instead of just a single row whereas we would like to be able to click on each row and reveal the data for that specific row exclusively.
I think the problem is do to with the data-target="#accordion" tag which targets the iteration of the collapsed data placeholder instead of the specific placeholder itself.
You can see an example here Twitter Bootstrap Use collapse.js on table cells [Almost Done] and here http://jsfiddle.net/whytheday/2Dj7Y/11/ but again the content is static and not dynamic.
The solution would be to have a "dynamic" data-target tag which matches the target id but I have no idea how to do that.