2012-08-25 2 views
1

URL에 해시가 포함 된 경우 테이블의 첫 번째 행을 다루는 tablesorter의 stickyHeaders 위젯에 문제가 있습니다.stickyHeader가 해시 링크의 대상 행을 덮습니다.

예 living.php? 탭 = 1 # sacramento1

페이지 올바른 탭을 표시하여 올바른 행으로 이동하지만, 헤더 행 위에 표시된다.

이 문제를 얻기 위해, 내가 stickyHeader 위젯을 사용하지 봤는데하면 URL을 여기에

에 해시가 있다면 것은 내가 뭘 내용은 다음과 같습니다

<script type="text/javascript">$(document).ready(function() 
{ 
    //CHECK for hash. don't want sticky headers with hash 
    if (window.location.hash) { 
    var workingID = window.location.hash; 
    tid=workingID.substr(1,workingID.length); 
    document.getElementById(tid).setAttribute("class", "showRow"); 
    // extend the default setting to always include the zebra widget. 
    $.tablesorter.defaults.widgets = ['zebra']; 
    } else { 
    // extend the default setting to always include the zebra widget and the sticky headers. 
    $.tablesorter.defaults.widgets = ['zebra','stickyHeaders']; 
    } 
    // extend the default setting to always sort on the first column 
    $.tablesorter.defaults.sortList = [[0,0]]; 
    // call the tablesorter plugin 
    $("table").tablesorter(); 
} 

);

stickyHeaders가 해시 행을 인식하여 헤더 아래에 표시 할 수있는 방법이 있습니까?

답변

0

에 한번이 코드 (demo) 추가 :

$('a').click(function(){ 
    if (this.hash !== "") { 
     window.location.hash = this.hash; 
     // find table that link is inside 
     var $table = $(this).closest('table'), 
      // get stickheader height + a little extra, 
      // if the link is in a table & table has a stickyheader... 
      shHeight = ($table.find('.tablesorter-stickyHeader').parent().height() || 0) * 1.2; 
     // move the anchor below the sticky header 
     $(window).scrollTop($(window).scrollTop() - shHeight); 
     // prevent anchor from controlling the scrollTop 
     return false; 
    } 
}); 

관련 문제