A very common use for drag and drop in content management systems is to sort lists. An important example of a list is the navigation of the site.
In this example, we'll look at how to sort a one-dimensional array—a very simple list that is not hierarchical.
To avoid the page flickering, which would happen if we obtained the list order after the page loaded and then displayed it, it makes sense to print out the HTML for the list in the right order in the first place. To do this, the file needs to be rendered with PHP.
Here's an example of what we want the browser to start with—save it as sorting-lists.p
hp
:
<html> <head> <script src="../jquery.min.js"></script> <script src="../jquery-ui.min.js"></script> <script src="sorting-lists.js"></script> <link rel="stylesheet" type="text/css" href="../jquery-ui.css" /> <style type="text/css"> ul{ list-style:none; width...