title: JQuery Datatables scrollbar and column search not working
body: <p>I am using <a href="https://datatables.net/" rel="nofollow noreferrer">JQuery DataTables</a> and trying to add a scrollbar to fit in the screen as well as column search in the header. It is <strong>breaking the header</strong> (if I click on the ordering, then my custom headers are gone) and the <strong>search doesn't work</strong> (happens only when the scrollbar is there).</p>
  
  <p>My code (don't change the html as I am adding all data dynamically):</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var table = $('#example').DataTable({
    "scrollX": true,
  });
  
  $('#example thead th').each(function() {
    var title = $(this).text();
    $(this).html('&lt;input type="text" placeholder="' + title + '" /&gt;');
  });
  
  table.columns().every(function() {
    var that = this;
  
    $('input', this.header()).on('keyup change', function() {
      if (that.search() !== this.value) {
        that
          .search(this.value)
          .draw();
      }
    });
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;table id="example" class="display nowrap" cellspacing="0" width="100%"&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;First name&lt;/th&gt;
        &lt;th&gt;Last name&lt;/th&gt;
        &lt;th&gt;Position&lt;/th&gt;
        &lt;th&gt;Office&lt;/th&gt;
        &lt;th&gt;Age&lt;/th&gt;
        &lt;th&gt;Start date&lt;/th&gt;
        &lt;th&gt;Salary&lt;/th&gt;
        &lt;th&gt;Extn.&lt;/th&gt;
        &lt;th&gt;E-mail&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;Tiger&lt;/td&gt;
        &lt;td&gt;Nixon&lt;/td&gt;
        &lt;td&gt;System Architect&lt;/td&gt;
        &lt;td&gt;Edinburgh&lt;/td&gt;
        &lt;td&gt;61&lt;/td&gt;
        &lt;td&gt;2011/04/25&lt;/td&gt;
        &lt;td&gt;$320,800&lt;/td&gt;
        &lt;td&gt;5421&lt;/td&gt;
        &lt;td&gt;t.nixon@datatables.net&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;Garrett&lt;/td&gt;
        &lt;td&gt;Winters&lt;/td&gt;
        &lt;td&gt;Accountant&lt;/td&gt;
        &lt;td&gt;Tokyo&lt;/td&gt;
        &lt;td&gt;63&lt;/td&gt;
        &lt;td&gt;2011/07/25&lt;/td&gt;
        &lt;td&gt;$170,750&lt;/td&gt;
        &lt;td&gt;8422&lt;/td&gt;
        &lt;td&gt;g.winters@datatables.net&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;Ashton&lt;/td&gt;
        &lt;td&gt;Cox&lt;/td&gt;
        &lt;td&gt;Junior Technical Author&lt;/td&gt;
        &lt;td&gt;San Francisco&lt;/td&gt;
        &lt;td&gt;66&lt;/td&gt;
        &lt;td&gt;2009/01/12&lt;/td&gt;
        &lt;td&gt;$86,000&lt;/td&gt;
        &lt;td&gt;1562&lt;/td&gt;
        &lt;td&gt;a.cox@datatables.net&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;Cedric&lt;/td&gt;
        &lt;td&gt;Kelly&lt;/td&gt;
        &lt;td&gt;Senior Javascript Developer&lt;/td&gt;
        &lt;td&gt;Edinburgh&lt;/td&gt;
        &lt;td&gt;22&lt;/td&gt;
        &lt;td&gt;2012/03/29&lt;/td&gt;
        &lt;td&gt;$433,060&lt;/td&gt;
        &lt;td&gt;6224&lt;/td&gt;
        &lt;td&gt;c.kelly@datatables.net&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;Airi&lt;/td&gt;
        &lt;td&gt;Satou&lt;/td&gt;
        &lt;td&gt;Accountant&lt;/td&gt;
        &lt;td&gt;Tokyo&lt;/td&gt;
        &lt;td&gt;33&lt;/td&gt;
        &lt;td&gt;2008/11/28&lt;/td&gt;
        &lt;td&gt;$162,700&lt;/td&gt;
        &lt;td&gt;5407&lt;/td&gt;
        &lt;td&gt;a.satou@datatables.net&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;Brielle&lt;/td&gt;
        &lt;td&gt;Williamson&lt;/td&gt;
        &lt;td&gt;Integration Specialist&lt;/td&gt;
        &lt;td&gt;New York&lt;/td&gt;
        &lt;td&gt;61&lt;/td&gt;
        &lt;td&gt;2012/12/02&lt;/td&gt;
        &lt;td&gt;$372,000&lt;/td&gt;
        &lt;td&gt;4804&lt;/td&gt;
        &lt;td&gt;b.williamson@datatables.net&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><a href="http://jsfiddle.net/cmxynxL8/25/" rel="nofollow noreferrer">Fiddle</a></p>