2013-04-16 87 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' 
    });