Infinite pagination with page numbers

I’m trying to enhance my infinitely paginated search results with page numbers that appear every 10 results (see http://scrollsample.appspot.com/items for an example). Using Blaze, I’m having a hard time doing this “correctly.” I’ve managed to implement a mostly working solution but it’s not tolerant of result resorting. Here’s my jQuery based solution:

Template.documentsTable.rendered = (->
  @autorun(=>
    page = (Session.get('limit') / 10) - 1;
    @$('#documents-table--table tbody tr:last')
      .addClass('pageRow')
      .removeClass('hidden')
      .find('td.page')
      .text(page)
  );
);

What’s a better way to correctly inject a view after N results and remove it when a re-sort occurs?

Thanks!