john doe
john doe

Reputation: 9652

Positioning the Popup in jQuery Mobile

I am having a hard time to position the popup on a specified position. Here is my code and for some reason it never displays at the specified coordinates.

$("#overlay").popup({
    transition: "slideup",
    shadow: false,
    corners: false,
    beforeposition: function (event, ui) {
        ui.x = 0;
        ui.y = 100;
    }
}).popup("open");

Upvotes: 0

Views: 392

Answers (1)

Rosberg Linhares
Rosberg Linhares

Reputation: 3687

Try to use $(this).css :

  • HTML:

    <div id="overlay" data-role="popup" data-tolerance="0">
    </div>
    
  • JS:

    $(document).on("pagecreate", function (event, ui) {
        $("#overlay").popup({
            transition: "slideup",
            shadow: false,
            corners: false,
            beforeposition: function (event, ui) {
                $(this).css({
                    left: 0,
                    top: 100
                });
            }
        });
    });
    

Here is a Demo.

Upvotes: 1

Related Questions