General
Sortable list woes
My previous post mentioned FireBug and how handy it is in tracking/debugging AJAX requests and code. This was particularly important as the problem I'm having is with Sortable lists (in tree form) and child elements not being serialized when they're added via AJAX. To explain a bit further, I'm using the technique to list the pages of a site, with sub-levels loaded in via AJAX so that you don't get loaded with a few hundred pages listed all at once when you only want to get to the home page. That bit's fine though - works perfectly. The problem is with the sortable part - here I've had no end of troubles. My first problem is that I'm no JavaScript god. I can generally figure out just about what's going on and write my own simple code, but I'm at no kind of level to be doing clever debugging. Doing sortable lists with a tree requires much clever debugging. Problem two lay in my use of semantic XHTML markup and the result that the sortable list items also include lists that shouldn't be sortable (lists of options). This initially breaks Sortable.serialize as the non-sortable list items don't have IDs in the form tag_x for serialization, which in turn makes the serialize function skip anything below that level. Not good. I tried adding in code to the serialize function to make it ignore the non-sortable lists, but this is where my JS skills hit a wall and in the end I've had to assign the option list items unfeasibly high ID numbers based on the page they're associated to (something along the lines of page_pageID000000000x). With that done (still working on the list starting showing two levels deep), the serialize function would get the whole lot and briefly I was happy. Alas, I then tried to add the code to load in sub-levels of pages via AJAX and of course the serialize function didn't see the 'new' list items as the Sortable had been created before them. A quick search of Google and a common sense approach of re-creating the Sortable at the time the new list items are inserted seemed the way to go. I found someone claiming it worked to just re-declare the Sortable.create but no luck for me. I'm still working on it :(