0

I am using AJAX to bring more data to my div and mcustomscrollbar to scroll. What I want is as soon as the data is loaded for my div to focus on the very element of the loaded data. For example, if the loaded data starts from 6 to 10 so div should show the data from 6. My code reads like this

function generatemCustomeScrollbar(elementID)
{
     $(elementID).mCustomScrollbar({
     scrollButtons: {
         enable: false
     },
     theme:"rounded",
     scrollEasing: "easeOut",
     moveDragger: true,
     mouseWheel: {scrollAmount: 200},
     keyboard: {enable: 1},
     keyboard: {scrollAmount: 200},
     keyboard: {scrollType: "stepless"},
     contentTouchScroll: 200,
     scrollbarPosition: "outside",
     alwaysTriggerOffsets: true,
     advanced: {
         updateOnBrowserResize: true,
         updateOnContentResize: true
     }
 });
}

I have initialize the scrollbar on document.ready...

generatemCustomeScrollbar(".myDiv");

and my ajax look like this... it's example

 $.ajax({
        type:'POST',
        url:base_url+'ajax_more_near_poi',
        dataType:'json',
        data:data_send,
        success: function(data){
        if(data.error_msg){
             $(".myParentDiv").html(data.error_msg);
        }else{
             console.log("success");
             $(".myDiv").append(data.html_detail);
        }
        overloading = false;
        },
        error: function(){
             console.log("error");
             overloading=false;
        }
  });
MSOACC
  • 3,074
  • 2
  • 29
  • 50
Rahul Gupta
  • 972
  • 11
  • 29
  • And where is the data added to the scollbar? This looks like the definition of the scollbar only – dmaij Mar 01 '16 at 11:43
  • myDiv is the div where I am loading the data through ajax.. like $(".myDiv").append("data.myData"); So everytime, I hit the button, data is appended into this div. – Rahul Gupta Mar 01 '16 at 12:54
  • I understand. I asked because basically you want to set the selection of the scollbar in the succes function of you ajax call. The element you want to select is the first element in data.myData, so this is where to find it. – dmaij Mar 01 '16 at 12:59
  • Sorry for late reply... was in the middle of the something... but i have posted my ajax call. – Rahul Gupta Mar 03 '16 at 12:42

0 Answers0