问题
I have used jScrollPane on my site. I'm also using ajax to update the data on the same div where the jScrollPane is used. Now, when i append the returned data to the div, the scrollbar is not visible on the appended text. It may because the jQuery function is called when the document loads but now any ideas to solve this problem? I read the article here here http://jscrollpane.kelvinluck.com/auto_reinitialise.html but i'm not being able to solve this problem. Here's the code:
function scrollfunction($value){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
$(ajaxRequest.responseText).appendTo(".div1");
}
}
ajaxRequest.open("GET", "process.php" , true);
ajaxRequest.send(null);
}
$("document").ready(function() {
$(".div1").jScrollPane();
});
回答1:
$("document").ready(function() {
$(".div1").jScrollPane({autoReinitialise: true});
});
Is there a good reason for not using jQuery's $.ajax, as I believe all the handlers and functions you are creating in your function is already built in to $.ajax.
$.ajax({
type: "GET",
url: "process.php",
dataType: "text",
success: function(data){
$(data).appendTo(".jspPane");
}
});
jspPane is normally the container created by jScrollPane, try appending directly to that container.
来源:https://stackoverflow.com/questions/7621048/jscrollpane-trouble