Dataset.getTotalCount is not working

You shouldn’t put dataset.onReady() inside an event handler.

  • you didn’t write any condition (I don’t see if else in your code)