Trigger an event at the bottom of screen with scrollview plugin for jquerymobile

Trigger an event at the bottom of screen with scrollview plugin for jquerymobile

Hi:

I would like to trigger an event when the user scrolls to the bottom of the page when using the scrollview plugin for jquerymobile.  This will be handy for "infinite scroll" functionality: as you get to the end of content items are added to the end of a list.  The scroll (and therefore the fun ;-) ) never ends.

I got it to work with a hack but I'd like to see if there was a cleaner way to do this.

At the bottom of the _stopMScroll function I added:
  1.         var c = this._$clip;
  2.         var v = this._$view;

  3.         var ch = parseInt(c.css("height"), 10);
  4.         var vh = parseInt(v.css("height"), 10);

  5.         /* if we are at the bottom of the screen trigger the event */         
  6.         if((vh - ch < 0) || ((vh - ch) == Math.abs(this._sy))) {
  7.           $(window).trigger("BottomOfPageHitEvent");
  8.         }
This throws the BottomOfPageHitEvent to the main window which is then handled by the rest of my code.  

Can anyone think of a cleaner implementation where I wouldn't have to hack scrollview itself?