Enable <table> (and <tr>) to be sortable.
Hello everyone,
and best whishes for the incoming new year.
I'm a new jquery user, and i want to use "sortable".
By default, the "sortable" function only works with lists (<ul> and <li>),
but i want to use it in a table,
to rearrange my rows.
I thought it would work with any <tag> as it has the right "class" or "id" but it won't.
(sorry for my english)
Here is my actuel code...(with <ul> and <li> tags)
(it calls a ajax file to save the change in a database, but i've moved this part of the code, 'cause it has nothing to do with my problem)
sortable.php
- <script src="js/jquery-1.9.1.js"></script>
<script src="js/jquery-ui-1.10.3.custom.js"></script>
<script src="js/jquery-ui-1.10.3.custom.min.js"></script>
<script>
$(document).ready( function(){
$("#list-roadbook").sortable({
placeholder: 'highlight',
update: function() {
var order = $('#list-roadbook').sortable('serialize');
$.post('ajax.php',order);
}
});
$("#list-roadbook").disableSelection();
});
</script>
<ul id="list-roadbook">
<li id="id_1">number 1</li>
<li id="id_2">number 2</li>
<li id="id_3">number 3</li>
<li id="id_4">number 4</li>
<li id="id_5">number 5</li>
<li id="id_6">number 6</li>
<li id="id_7">number 7</li>
<li id="id_8">number 8</li>
<li id="id_9">number 9</li>
<li id="id_10">number 10</li>
</ul>
</body>
The ".js" files are up to date (it has be downloaded yesterday... and i didn't modify it).
Thank you for your support.