开发者

sorting definition list with jquery

开发者 https://www.devze.com 2023-01-04 15:01 出处:网络
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.

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:

  1. 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)

  2. 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>
    
  3. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消