2013-04-16 89 views
1

我正在使用Jquery UI对话框来显示一个弹出框打开jQuery对话框时保持滚动位置

我有一个网格页面。每行都有一个图标打开一个对话框

如果有很多行,并且需要向下滚动并单击底部的一行,那么当对话框打开时,它也会将页面再次滚动到顶部

有什么办法可以防止这种情况发生?

我只是想打开对话框,并在页面滚动位置维持

$('#AmendLineDialogBox').dialog({ 
      autoOpen: true, 
      modal: true, 
      closeOnEscape: true, 
      buttons: 
       { 
        'Ok': function() { 
// ...snip 
          $(this).dialog("close");     
        }, 
        'Cancel': function() { 
         $(this).dialog("close"); 
        } 
       }, 
      position: 'center', 
      title: 'Amendment' 
     }); 
+0

尝试添加“返回false;”调用此对话框后。 –

+0

打开对话框的图标是否包含在''中? – Jai

+0

'#AmendLineDialogBox'其ID是这个图标还是? – Jai

回答

1

你可以做链接是这样的:

$('#AmendLineDialogBox').click(function(e){ 
    e.preventDefault(); //<--------------^-------prevent the default behaviour 
}).dialog({ 
     autoOpen: true, 
     modal: true, 
     closeOnEscape: true, 
     buttons: 
      { 
       'Ok': function() { 
// ...snip 
         $(this).dialog("close");     
       }, 
       'Cancel': function() { 
        $(this).dialog("close"); 
       } 
      }, 
     position: 'center', 
     title: 'Amendment' 
    });