Gene R Gene R - 1 year ago 87
jQuery Question

jQuery sortables

I'm using the sortable function in jquery to sequence a faq list. Needless to say, i'm new to this concept. Anybody have any good examples of the backend for this. I have the front working fine, but updating the sequence in the database is another story. My backend is ColdFusion btw.

Thanks in advance

Answer Source

Define the faq:

<div id="faq">
  <div id="q1">...</div>
  <div id="q2">...</div>
  <div id="q100">..</div>

Make faq sortable:

<script type="text/javascript">

Form submitted:

<form action="..." id="faq_form">
  <input type="hidden" name="faqs" id="faqs" />

Add sorted sequence to form

<script type="text/javascript>
  $("#faq_form").submit(function() {

When form is submitted, field "faqs" will contain comma separated id's from #faq like this: q1,q3,q10,q11,q2,q100...

Just parse it and save to DB

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download