title: Enable and disable jquery sortable on click
body: <p>I have a button that I toggle on click. This button enables the jquery sortable class on a list in my html called "subtaskTaskList". However, I can get the button to toggle but the sortable enable and disable doesn't seem to respond. See code below.</p>
  
  <pre><code>&lt;button id="sortButton" class="btn btn-default btn-xs"&gt;&lt;span class="glyphicon glyphicon-adjust"&gt;&lt;/span&gt;&lt;/button&gt;
  
   $("#sortButton").click(function(){
      if($("#sortButton").hasClass("glyphicon-adjust")){
          $("#subtaskTaskList").sortable();
          $("#sortButton .glphyicon").toggleClass("glyphicon-adjust glyphicon-lock");
      }else{
       $("#subtaskTaskList").sortable('disable');
          $("#sortButton .glphyicon").toggleClass("glyphicon-lock glyphicon-adjust");
      }
  });
  </code></pre>
  
  <p>This code leaves me with an error in my console saying sortable can't be disabled if it had not be initialized. I have tried variations of this code including:</p>
  
  <pre><code>$("#sortButton").click(function(){
      if($("#sortButton .glyphicon").hasClass("glyphicon-adjust")){
          $("#subtaskTaskList").sortable();
          $("#sortButton .glphyicon").toggleClass("glyphicon-adjust glyphicon-lock");
      }else{
       $("#subtaskTaskList").sortable('disable');
          $("#sortButton .glphyicon").toggleClass("glyphicon-lock glyphicon-adjust");
      }
  });
  </code></pre>
  
  <p>as well as:</p>
  
  <pre><code>$("#sortButton").click(function(){
      if($("#sortButton").find("span").hasClass("glyphicon-adjust")){
          $("#subtaskTaskList").sortable();
          $("#sortButton .glphyicon").toggleClass("glyphicon-adjust glyphicon-lock");
      }else{
       $("#subtaskTaskList").sortable('disable');
          $("#sortButton .glphyicon").toggleClass("glyphicon-lock glyphicon-adjust");
      }
  });
  </code></pre>
  
  <p>The latter two piece of code don't even cause for toggling of the glyphicon. Any input would be greatly appreciated. I looked over stack overflow but haven't found any specific questions dealing with this issue.</p>