1

I'm writing Cordova project with jQuery Mobile.I have the code to detect user scroll to the bottom.It's work but I don't know why the code need to be placed inside deviceready event handler? Waiting for something get ready?

function onDeviceReady() {
    $(window).scroll(function () {
        if ($(window).scrollTop() + $(window).height() == $(document).height()) {
            alert("bottom!");
        }
    });
}
Niklas
  • 955
  • 15
  • 29

1 Answers1

0

Please read this as that should help. JQuery document.ready vs Phonegap deviceready

I am also adding the required code once device is ready and document is loaded to avoid any issue like variable not declared, class not found etc. In simplest form it means once device is ready(alot of backgound activites happens for the phonegap app from the time it shows the splash screen(I am using sencha touch based phonegap app) page is loaded completely(all elements analyzed), then only user scroll can be determined that it reaches to bottom/end of the document(js loaded completley and reacting to events). This is my understanding

Community
  • 1
  • 1
adang
  • 547
  • 4
  • 14