watusi / jquery-mobile-iscrollview

JQuery Mobile widget plug-in for easy use of the iScroll javascript scroller.
407 stars 183 forks source link

Scroll to element not working #134

Closed sureshpattu closed 9 years ago

sureshpattu commented 10 years ago

I Trying to use the scroll to element function in the jquery mobile Iscroll But its not working This is what my script looks like I tried here MyJsfiddle http://jsfiddle.net/cX4bk/

$('[data-role="content"]').trigger('create'); $(".scroll-wrapper").iscrollview(); $(".scroll-wrapper").iscrollview('refresh');

$('.chequeBanks').click(function(){
    $(".scroll-wrapper").iscrollview('refresh');
     var bankId=$(this).val();
     $('.accNumber').html($('.chequeBankDetailsSec .bankId-'+bankId+' .number').html());
     $('.details').show();
     $('.details').show();
     var x = $('.details').offset().left;
     var y = $('.details').offset().top;
    $(".scroll-wrapper").iscrollview("scrollTo", x,y, '1');
});
jtara commented 9 years ago

The scrollToElement() function exists for this purpose. You just need a selector that will select the element you want to scroll to. Don't try to do it yourself by calculating position and using scrollTo().