title: knockout and JQuery UI drag and drop form builder
body: <p>I want to implement a form builder using knockout and JQuery UI. </p>
  
  <p>I found Knockout sortable plugin plus some more material and I implemented a framework for the form builder. </p>
  
  <p>Basically I have an observable array that holds all my available field types with their proprieties and another one that holds the controls that have been added to the form. I added a binding that would add me a field just by clicking on it so it would save the fast users from the time of dragging and dropping. Also a click event on the added fields that would go to the field details (now only displays an alert).</p>
  
  <p>I want to assign an id for every form element that is added to the form. If another element is added to the form it should have an incremented id and if the elements within the form are rearranged the id's of the elements should be changed as well.</p>
  
  <p><strong>My question</strong> is where and how should I perform this ID assignment and then reassignment so every time a new field is added or moved around the id's of the form element would be in consecutive order.</p>
  
  <p>I assume that I could assign an id for every dropped element in the binding handler but how can I control it afterwards?:</p>
  
  <pre><code>$(element)[0].id = 'field-nr-' + globalVariable++;
  </code></pre>
  
  <p>This would also mean that I have to change the Knockout Sortable plug-in, witch I'm trying to avoid.</p>
  
  <p>The code is in this fiddle : <a href="http://jsfiddle.net/razvangl/z52G7/" rel="nofollow">http://jsfiddle.net/razvangl/z52G7/</a>    </p>