Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 361
Omu Avatar asked Feb 01 '11 14:02

Omu


2 Answers

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;
        });
    });
like image 52
Mark Coleman Avatar answered Nov 11 '22 23:11

Mark Coleman


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.

like image 26
Gergely Fehérvári Avatar answered Nov 12 '22 00:11

Gergely Fehérvári