There are two sorting links, SortName, SortDate. When using jquery load to load a table ($ ('table.listing'). Load ...) then it works. When using $ ('form'). Load ... then this will not work. Why is this?
The code below works, but if you change "table.listing" to "form", it will not work. The problem is that the links also have to load, and they are in the div above the table, so I need to use a “form” or some kind of div, although the div wrapper also does not work.
Which means that this will not work: if you use the “form”, you need to click the TWICE links to load the container !?
<form method="post">
<div>
<a href="" id="sortn">SortName</a><br/>
<a href="" id="sortd">SortDate</a>
</div>
<table class="listing">
...table code here
</table>
</form>
<script type="text/javascript">
$(document).ready(function(){
$('a#sortn').click(function(event) {
event.preventDefault();
$('table.listing').load('index.php?sort=1 table.listing');
});
$('a#sortd').click(function(event) {
event.preventDefault();
$('table.listing').load('index.php?sort=2 table.listing');
});
});
</script>
Marko source
share