Hello, all,
I'm very new to jQuery and jQuery Mobile.
I try to load some data from an external database and show each row in a collapsible, but it doesn't work even when I replace the dynamic data with static html. What I'm trying is this:
On my page I have:
<div id="tableContents">
</div>
In JS I do:
$(document).ready(loadData);
and loadData does this:
$( "#tableContents" ).load( 'some.html', '#table' );
$('#tableContents').trigger('create');
And some.html contains:
<div id="table" data-role="collapsible" >
<h3 id="tableHeader2">
<table id="th2">
<thead>
<tr>
<th>Spalte 17</th>
<th>Spalte 22</th>
</tr>
</thead>
<tbody>
<tr>
<td>Wert 123</td>
<td>Wert 234</td>
</tr>
</tbody>
</table>
</h3>
<table id="tr22">
<thead>
<tr>
<th>Spalte 34</th>
<th>Spalte 44</th>
</tr>
</thead>
<tbody>
<tr>
<td>Wert 345</td>
<td>Wert 456</td>
</tr>
</tbody>
</table>
<table id="tr123">
<thead>
<tr>
<th>Spalte 61</th>
<th>Spalte 72</th>
<th>Spalte 82</th>
</tr>
</thead>
<tbody>
<tr>
<td>Wert 66</td>
<td>Wert 77</td>
<td>Wert 88</td>
</tr>
</tbody>
</table>
<!-- </div> -->
</div>
On the original page I have a similar Collapsible. This is loaded correctly and to the "div" with data-role=collapsible are added some classes and inserted some divs and an a-Tag which cares fore rendering the collapsible.
The data from some.html looks exactly the same as the original in the main page.
But after loading I can only see the data.
If I watch this in firebug I can see the following:
After loading the div with data-role=collapsible (from some.html) is being added the classes and inserted other divs and an a-Tag as in the static collapsible. But suddenly all this added data is removed again.
If I stop in the debugger when the new classes and divs are added, they stay and do not disappear and all works fine.
It seems as after trigger.('create') all is loaded correctly, but after that a second event is fired which removes all the new data. What could this be?
Besides trigger.('create') I tried enhanceWithin, collapsible.('refresh') and some others, but nothing worked.
Can anyone help?
Thanks a lot, Gerhard