jQuery is Javascript, if there was any confusion.I'm assuming it's a javascript solution be I haven't found any good examples of that. Or is there a jQuery solution to that?
You can use jQuery to get the new ordering of elements in either (or both) list(s); here's one approach:
This is making some assumptions about your code and how you want to handle things. It assumes you'll have a form with id "myFormId," and that upon submission, it will gather the list items in #sortable2 and make a comma-separated string of their text in consecutive order, and then append that string to the form as a hidden input named "listItems".Code:$('#myFormId').submit(function(){ var listItems = ''; $('#sortable2 li').each(function(){ listItems += $(this).text()+','; }); $(this).append('<input type="hidden" name="listItems" value="'+listItems+'"'); });
So you have some options to consider: do you want to use form submission? Would you rather use AJAX? Will a comma-separated list be an appropriate data format to use? Is there something more ideal? All things you can change, depending on what you want.




Reply With Quote