At the moment I have two (maybe more) unordered lists which are sortable with jquery and ui.
The things that work are that the lists are connected, items are draggable, items can be removed and a form that adds to the list.
What I need however is a function that gets all the content for li items and json encode them ready to be sent off to some db function, or something.
Im new to jquery however and cant find documentation for li items.
Hope Ive explained this well.
Daniel
UPDATE - Sample Code
<script type="text/javascript">
function addSortable(value) {
$("#sortable1").prepend("<li class='ui-state-default' id='"+value+"'><span class='ui-icon ui-icon-arrowthick-2-n-s'></span>"+value+"</li>");
}
function deleteItem(value) {
$("#item-"+value).fadeOut('slow');
$('#sortable1 li').each(function() {
var text = $(this).text();
});
document.getElementById('jsoningreds').innerHTML = text;
}
$(function() {
$("#sortable1, #sortable2").sortable({
connectWith: '.connectedSortable'
}).disableSelection();
});
</script>
<ul id="sortable1" class="connectedSortable">
<li id="item-0" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>8 large chicken thighs, skinned <a href="javascript:deleteItem(0)" class="deleteItem"></a></li>
<li id="item-1" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>seasoned flour (celery salt, cayenne pepper, paprika and white pepper) <a href="javascript:deleteItem(1)" class="deleteItem"></a></li>
<li id="item-2" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>2 small eggs, beaten <a href="javascript:deleteItem(2)" class="deleteItem"></a></li>
<li id="item-3" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>100g butter <a href="javascript:deleteItem(3)" class="deleteItem"></a></li>
</ul>
<hr />
<h3>Recipe number 2</h3>
<ul id="sortable2" class="connectedSortable">
<li id="item-5" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>3 tsp vegetable oil <a href="javascript:deleteItem(5)" class="deleteItem"></a></li>
<li id="item-6" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>1 bay leaf <a href="javascript:deleteItem(6)" class="deleteItem"></a></li>
<li id="item-7" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>250g onions, finely sliced <a href="javascript:deleteItem(7)" class="deleteItem"></a></li>
</ul>
<p id="jsoningreds">hello</p>