i got a problem with my app.i'm developing an app with cordova & jquery mobile.
Following the code on jquery mobile master i found that code

```
function openPopup(idPopup, onTimeout) {
    var popupContent = '<div data-role="content" data-theme="a" style="border:0px;" class="ui-corner-bottom ui-content centerContent">' +
        '<h3 class="ui-title" id="myTitle">Caricamento</h3>' +
        '<img src="img/load_shop33sell.gif"/></div>';
    var popup = '<div data-role="popup" id="popup-' + idPopup + '" data-overlay-theme="b" data-theme="a" class="ui-content">' + popupContent + '</div>';
    $.mobile.activePage.append(popup).trigger("pagecreate");
    $("#popup-" + idPopup).on({
        popupbeforeposition: function () {
            $('.ui-popup-screen').off();
        }
    });
    var fallback = setTimeout(function () {
        $("#popup-" + idPopup).popup("open");
    }, 3000);
    $("#popup-" + idPopup).popup("open");
    clearTimeout(fallback);
    callback = setTimeout(function () {
        $("#popup-" + idPopup).popup('close');
        if (onTimeout && typeof (onTimeout) === "function") {
            onTimeout();
        }
    }, 20000);
}

```

With this code, i am able to open a popup without needing to include a 

```
<div data-role="popup">..../<div>

```

in each page i create.I just modified a bit adding the popupbeforeposition event to make the popup undismissable by clicking on the background.
Well, it works fine but i got a problem. Randomly in my first page this happens

![First image](https://i.stack.imgur.com/Ta81Y.png)

Seems like the popup opens before it get the right position. In addition i have a second page which is scrollable, and i always have this situation. If i try to scroll up to the top of the page, i have half of the screen black, as in first picture.
![enter image description here](https://i.stack.imgur.com/o6iWv.png)

What could be the problem?

Thanks in advance, and sorry for my english :)