6

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?

2 Answers 2

9

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;
        });
    });
Sign up to request clarification or add additional context in comments.

2 Comments

i think this is too complicant. just use javascript:void(0) and thats all... that is the reason of scrolling, and this is alsoo very unnecesarry to create an event to each button for the click, only change the href.
javascript:void(0) would work as well however I do not know the extent of the application. It is possible the href might be used for something if javascript is disabled.
5

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.

1 Comment

the page is not reloaded.. it just goes to the top due to the # in the links

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.