How do I prevent scrolling to the top of a page when popping up a jQuery UI Dialog?

前端 未结 4 1681
旧时难觅i
旧时难觅i 2020-12-15 17:26

I currently use jTemplates to create a rather large table on the client, each row has a button that will open a jQuery UI dialog. However, when I scroll down the page and cl

4条回答
  •  不思量自难忘°
    2020-12-15 17:31

    Are you using an anchor tag to implement the "button" that pops the dialog? If so, you'll want the click handler that opens the dialog to return false so that the default action of the anchor tag isn't invoked. If you are using a button, you'd also need to make sure that it doesn't submit (by returning false from the handler) and completely refresh the page.

    For example,

    $('a.closeButton').click( function() {
         $('#dialog').dialog('open');
         return false;
    });
    
    
    Close
    

提交回复
热议问题