KMP
KMP

Reputation: 35

Accordion position and scrollto

I have the following accordion working but having trouble figuring out how to make the first item not scroll to first item position which is on the middle of the page.

I want the following items in the accordion to scroll up to next item start when clicked. Also when any item is opened and closed the code no longer works.

But if you select items without closing open item then code works smoothly. Thanks for any assistance.

$("#accord_holder").accordion({
    autoHeight: false,
    collapsible:true,
    navigation:true,
    active:false,
    change: function(event, ui) {
    $(window).scrollTop(ui.newHeader.position().top - 1);
    }
   });

Upvotes: 0

Views: 405

Answers (2)

Arpit
Arpit

Reputation: 12797

Here is the error

change this

  $(window).scrollTop(ui.newHeader.position().top - 1);

into

   $(window).scrollTop(ui.newHeader.position.top - 50);

Updated your fiddle http://jsfiddle.net/rwyvh/37/

Upvotes: 1

Brian Ogden
Brian Ogden

Reputation: 19212

$("#accord_holder").accordion({
    autoHeight: false,
    collapsible:true,
    navigation:true,
    active:false,
    change: function(event, ui) {
     //this might work
     $(this).scrollTop($(this).scrollHeight);
    }
   });

Upvotes: 0

Related Questions