2014-04-22 1 views
0

ajax를 사용한 후에 jScrollPane을 다시로드하는 데 문제가 있습니다. 이 문제는 많이 묻는 것 같지만, 아직 (시간을 들인 후) 알아 내지 못했습니다. 내가 JScrollPane의를 reintitialising거야하지만 그래서 여전히 DIV의 콘텐츠 후 오지 않는 아약스에 의해 대체되고있는jScrollPane with Ajax

function search(str) { 
    var xmlhttp; 
    if (window.XMLHttpRequest) { 
     xmlhttp = new XMLHttpRequest(); 
    } 
    else { 
     xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
    } 
    xmlhttp.onreadystatechange = function() { 
     if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { 
      document.getElementById("searchresult").innerHTML = xmlhttp.responseText; 
      document.getElementById("searchresult").style.display = "inline"; 
      $('.searchresult').jScrollPane({autoReinitialise: true}); 
     } 
    } 
    xmlhttp.open("POST", "ajax/search.php", true); 
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
    xmlhttp.send("q=" + str); 
} 

:

그래서 여기 내 자바 스크립트 코드입니다.

모든 솔루션?

답변

0

나는 그것을 API getContentPane으로 해결할 수 있었다.

나는 스크립트의 상단에 다음 코드를 추가 :

$(document).ready(function() { 
    jQuery('.searchresult').jScrollPane({ 
     showArrows: true, 
     autoReinitialise: false 
    }); 
}) 

그리고 나는이 대체 :

document.getElementById("searchresult").innerHTML = xmlhttp.responseText; 
document.getElementById("searchresult").style.display = "inline"; 
$('.searchresult').jScrollPane({autoReinitialise: true}); 

과 :

api = jQuery("#searchresult").data('jsp'); 
api.getContentPane().html(xmlhttp.responseText); 
document.getElementById("results").style.display="inline"; 
api.reinitialise();