Gene R Gene R - 10 months ago 49
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


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