Sorting a list alphabetically and sending list items to a new list
Wed September 2 '09 12:09 AM Category: ColdFusion , JQueryLast week I spent some time developing an application that gathers a list to contain up to 500 items. I was trying to decide the best method of sending the list items from one list to another and be quick and easy. I am sure there is a way to do this but I like the idea of sending items to another list better.Ā I decided to use some JQuery and make this widget:
My favorite part was the simplicity of both functions. The first being sendTo(this). Instead of changing the click event, I used the element's state and checked it's location for deciding to send it to the other location. The second was to keep the lists sorted alphabetically so if the user decides to remove a list item, it will place it back exactly where it came from. This link is where I found information on how to use a function inside of the sort() method to choose what content to sort within the <li> tag. Sorting occurs on page load and when any list item is moved.
It would be an improvement to use DOM to build the alphabet navigation. Since the list is output in server code, it is much easier to build it using whatever structure is available for filling up the list with items. The only improvement would be removing that letter from navigation when there are no more items under it.
Loading...
Recent Comments