I can use jQuery UI to make an ul sortable. I can do the same with a group of divs. This means that each item can move and change position.
1- It seems that it is not possible to do a form sortable, is that correct?
2- One solution I tried is to put each form input inside a li or a div. But, is this the best way to do it?
JQUERY:
$(function() {
$('#sortable').sortable();
});
HTML:
<ul id="sortable">
<li id="1">item1</li>
<li id="2">item2</li>
<li id="3">item3</li>
</ul>
<form id="sortable" action="extern.php" method="post">
<input type="text" id="item1" name="item1" value="" ><br>
<input type="text" id="item2" name="item2" value="" ><br>
<input type="text" id="item3" name="item3" value="" ><br>
</form>
Sortable() has an option named cancel with the default: "input, textarea, button, select, option" that prevents sorting if you start on elements matching the selector.
$("#sortableList").sortable({ cancel: null });
And you should be good.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With