Omu
Omu

Reputation: 71288

when opening a jQuery UI dialog page scrolls up

you can see it here: http://mrgsp.md:8080/awesome/lookupdemo (make your browser window smaller, scroll down and click on a button near a textbox)

is there a way to make it not scroll up?

Upvotes: 6

Views: 3881

Answers (2)

The problem is that the links are refered to the "#" which is the page top. If you change this to href="javascript:void(0)" this will not link to anything and will not scroll up.

Upvotes: 5

Mark Coleman
Mark Coleman

Reputation: 40863

since you are using anchor tags you need to suppress the default behavior of the element. by calling preventDefault()

$("a").click(function (event) {
    event.preventDefault();
    //do stuff
}

Looking at your current javascript, something like this should work for you:

   $("#lpo" + o).click(function (event) {
        event.preventDefault();
        if (lckPerson != null) return;
        lckPerson = true;
        $.get('/awesome/PersonLookup', {
            prop: o,
            paging: 'true'
        }, function (d) {
            $("#lp" + o).html(d).dialog('open');
            lckPerson = null;
        });
    });

Upvotes: 9

Related Questions