sorting definition list with jquery
Having spot of bother sorting a definition list with jquery sortable. I have a handle on the dt but need it to select the following dd as well so the draggable object is actually both dt and dd tags.
Obviously these have no unique parent elem开发者_如何学Pythonent with the dl so just wondering if there is something I'm missing in the docs or do I have to add divs and contaminate my markup.
Any tips would be greatly appreciated...
I'm doing this now. If you found a solution then post it =)
Here are my proposed solutions:
Change your list to a UL containing headers (instead of DT) with content (could be a UL if you have more than one DD or could be a simple P element)
Add classes to your DT/DD so that they can be connected to each other. In my case I have days of the week which are shared classes of each:
<dt class="term thursday">Thursday</dt> <dd class="description thursday>Lorem ipsum</dd>
You could review the HTML standards and see if block elements (like DIVs) are allowed within a DL, and could group the DT/DL's together in a div (but the browser might explode if this isn't ok.)
I moved to a UL with LI's that contained a header and another UL (since I would have had multiple DD's):
<ul>
<li>
<h3>Previous DT Element</h3>
<ul>
<li>Previous DD</li>
<li>Another previous DD</li>
</ul>
</li>
<!-- more LI's as necessary -->
</ul>
It is now a zillion times easier to sort with TinySort or anything else.
精彩评论