1

I have an anchor link that points to a field that is inside a collapsible panel (it could be inside a panel that is inside a panel). I have code that when the user clicks on the anchor link, all the parent panels will open if it's hidden and scroll to the field by using jQuery offset().top. However, the value from offset() is not updated after the panel is open. Some sample code:

$anchor.click(function() {
  $.each($panels, function(key, panel) {
    if (\\ panel is closed) {
      $(panel).collapse('show');
    }
  })
  $('html,body').animate({scrollTop: $(this.hash).offset().top}, 'slow');
});

How to fix this issue?

BPm
  • 2,924
  • 11
  • 33
  • 51

1 Answers1

0

Was this section a mistake? Or did you take out the logic?

if (\\ panel is closed)

Also, I think you should be using this.href to access the link target instead of this.hash? Are you able to post the 'a' element's code?

This question seems to be similar.

Community
  • 1
  • 1
theatlasroom
  • 1,126
  • 9
  • 12
  • I omitted the condition. It is just a normal `a` element though... I don't think that is the problem. The problem is when I get the field's offset, it's always the old offset and not the updated one after the panel is expanded. – BPm Jun 12 '14 at 06:22