title: Dynamically checking and unchecking a task tree
body: <p>I'm having issues making a task tree I have dynamically check boxes. Basically if a top level (parent task) is checked, I would like it to check all of the subtasks (child boxes). I have this working on one of my task trees, but for some reason can't get it to work for my other.</p>
  
  <pre><code>&lt;script&gt;
  $(function() {
  
      $.ajaxSetup( { cache: false } );
      $('.task-tree').tree({
          ui: {
              theme_name: 'checkbox'
          },
          plugins : {
              checkbox: { three_state: false }
          },
          callback: {
              onload: function( tree ) {
                  tree.open_all();
                  $('.task-tree li a').each( function() {
                      var taskID = GetIdNum( $(this).attr('id') );
                      if ( $('#Task' + taskID + 'Enabled').val() == 1 )
                      {
                          console.log( $(this).parent() );
                          jQuery.tree.plugins.checkbox.check( $(this).parent() );
                      }
                  });
              },
              onchange: function( node, tree ) {
                  var selectedID = GetIdNum( $(node).find('a').attr('id') );
                  var required = $('#Task' + selectedID + 'Required').val();
                  console.log( 'REQ --&gt; ' + required );
  
                  if ( required == 1 )
                  {
                      return false;
                  }
                  else
                  {                   
                      $('.task-tree li a').each( function() {
                          var taskID = GetIdNum( $(this).attr('id') );
                          console.log( taskID );
                          $('#Task' + taskID + 'Enabled').val(1);
                      });
                      console.log( '----------------------------------------------' );
  
                      var unchecked = jQuery.tree.plugins.checkbox.get_unchecked(tree).find('a.not-required');
                      $(unchecked).each( function(){
                          var taskID = GetIdNum( $(this).attr('id') );
                          console.log( taskID );
                          $('#Task' + taskID + 'Enabled').val(0);
                      });     
                      console.log( '*************************************************' );
                  }
              }
          }
      });
  
  });
  </code></pre>
  
  <p></p>
  
  <p>Let me know if you need any more info about the problem.</p>