title: Jumble Word Game using jQuery ui-sortable
body: <p>I am trying out a jumble word game using jQuery ui-sortable where users can try swapping the elements and submit their answer. Here, the user will be given two opportunities. In case if the user fails in his first submission of answer, he will be given another chance by freezing the correct characters which means not allowing to move the correct characters. I want only the wrong characters to be moved or exchanged between the other wrong characters. I tried the below code</p>
  
  <pre><code>$("#word_"+i).sortable({
                  axis: 'x',
                  items: 'label:not(.correctText)',
                  cancel: '.correctText',
                  scrollSensitivity: 1,
                  tolerance: "pointer" ,
                  start: function(){
                      $(this).find("label:not(.ls)").each(function () {
                          $(this).data("fixedIndex", $(this).index());
                      });
                  },
                  change: function(){
                   $(this).find("label:not(.ls)").each(function () {                       
                      attrID = $(this).closest(".ui-sortable").attr("id");                        
                      if($(this).data("fixedIndex")!=0)
                      {
                        $(this).detach().insertAfter($("#"+attrID+" label:eq(" + ($(this).data("fixedIndex")-1) + ")"));                          
                      }
                      else
                      {
                        $(this).detach().insertBefore($("#"+attrID+" label:eq(" + ($(this).data("fixedIndex")) + ")"));
                      }
                    }); 
                  }
              });
             $("#word_"+i+" label.correctText").disableSelection();          
  }
  </code></pre>
  
  <p>I am able to freeze correct elements by using the above logic but not for consecutive correct characters, if i move second and third letters to its correct position and submit. Its getting freezed but when i try to move the first wrong element to somewhere right, then i am into trouble. It moves the correct characters to wrong position.</p>