wmh/jquery-scrollbox

Scroll to top on forward/backward

Closed this issue · 3 comments

I have a few divs using scrollbox that are in an iframe, which is in a modal popup. When I click the backward or foward navigation buttons, the iframe scrolls to the top. I need it to only do the horizontal scroll on my scollbox div and nothing else.

jQuery('#imgs-' + Id + '-backwardlink').click(function () {
jQuery('#imgs-' + Id + '').trigger('backward');
});
jQuery('#imgs-' + Id + '-forwardlink').click(function () {
jQuery('#imgs-' + Id + '').trigger('forward');
});

" class="scroll-img imgs-scrollBox" style="width: 675px; margin: 0 auto;">
    ">
wmh commented

@fubak Maybe you need to add preventDefault to the click event, see : http://api.jquery.com/event.preventdefault/

I tried this and had the same results...

jQuery('#imgs-' + Id + '-backward').click(function () {
jQuery('#imgs-' + Id + '').trigger('backward');
this.preventDefault();
});

Got it. I had to add onclick="return false;" to the element. Thanks!