title: Shiny Datatables - focus after page load
body: <p>So I'm trying to make it so that a datatable in my shiny app scrolls to the top and focuses on an element after someone clicks on the next page. The following code is working, but the problem is that the focus works whenever its drawn (because of drawCallBack)</p>
  
  <pre><code>options=list(pageLength=50, drawCallBack = DT::JS(
        'function (paginateScroll) {
          $("html, body").animate({
            scrollTop: 0
          }, 300);
          $("th:first-child").focus();
          $(".paginate_button").bind("click", paginateScroll);
        }'
      ))
  </code></pre>
  
  <p>I know there's an event called page (<a href="https://datatables.net/reference/event/page" rel="nofollow">https://datatables.net/reference/event/page</a>) which should work, but I can't seem to get the code right. Can anyone help me out?</p>