On 6 September 2010 17:25, Richard Quadling <[email protected]> wrote: > Hi. > > I'm about to go home and have a question for tomorrow's work. > > 1 - Take a <div> container. > > 2 - Use AJAX to add a bunch of labels/checkboxes. The labels are > supplied alphabetically sorted. > > 3 - Use JS to tidy the label widths so that the display looks like columns. > > 4 - Add an attribute to the labels indicating the column/row ordering > to be used. > > 5 - Sort the labels based upon the column/row ordering so that you > read the data in columns (e.g. a - g in col1, h - m in col2, etc.) > > I've got this working, but I don't think it is particularly efficient. > > So to my question. > > Can I sort the children of a container so that after the sort, the > children are displayed in the new order? > > Currently, I have to ... > > 1 - Add the labels to the container (inserting template.evaluate()'s > at bottom of container element). > > 2 - Read all the elements into an array. > > 3 - Sort the array. > > 4 - Zap the container. > > 5 - Re-add the elements. > > > I think I'd have to bubble sort the container's children by hand ... > > Is that an appropriate solution? > > Can I say something like (pseudo) ... > > holdingElement = container.childElement[x]; > container.childElement[x] = container.childElement[y]; > container.childElement[y] = holdingElement; > > sort of thing. > > > > > -- > Richard Quadling > Twitter : EE : Zend > @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY >
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_22066768.html informs me that I have to re-insert the item into the DOM for this to trigger a redraw (I think that's what it is telling me). -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
