title: Jquery button behavior for select all in datatable.
body: <p>I am writing a selectall button for the jquery datatable in my application. But the button is behaving in inconsistent manner and double clicking the button actually unselects the checkboxes in datatable. Here is my code for the button click event. sampleTable is my jquery datatable.</p>
  
  <pre><code>$("#button_select_all").click(function () {
         $(allSamplesTable.fnGetFilteredNodes()).find(':checkbox').each(function () {
         $this = $(this);
         $this.attr('checked', 'checked');
  
                      for (var i = 0; i &lt; _sampleTableExports.length; i++) {
                          if (_sampleTableExports[i]["Id"] == $(this).val()) {
                              _sampleTableExports.splice(i, 1);
                              return true;
                          }
                      }
                      _sampleTableExports.push({ "Name": $(this).attr("name"), "Id": $(this).val() });
                  });
  
              });
  </code></pre>
  
  <p>Kindly advise why the button is unslecting the checkboxes in the 2nd click. </p>