You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been having trouble using an anchor tag as a trigger.
The use case for this is I have 5-10 frequently asked questions and i would like to have anchors to each question and also a mechanism to scroll to the correct question if the url contains a hash parameter.
In the past (using bootstrap3) this was possible and I simply return false or event.preventdefault on the anchor allow the accordion override the anchor functionality.
I have worked around it by wrapping my anchor with another div and using that as a trigger and using css to prevent clicks on anchor tag obscuring/intercepting the wrapping trigger event listener but this is not ideal.
Another issue I noticed is when I initialize the accordion to have a specific question open, via the openOnInit parameter, it does not fire the onOpen or beforeOpen event which I was relying on to begin the scroll down the page.
I have been able to work around both issues but it would be nice to have better support on those two features built in.
Thanks for your time and thanks for this great accordion script.
The text was updated successfully, but these errors were encountered:
Auto-scrolling to the specified element is possible by adding a unique ACCORDION_ID and using the #ACCORDION_ID hash in the URL. This behavior is unrelated to the Accordion package, and I don't see why a link with href="#ACCORDION_ID" wouldn't work.
On the other hand, if you want to scroll to the element if the element has been opened, you can use onOpen fn
When it comes to the second issue, methods such as onOpen won't be triggered when openOnInit is set, but if you want to bypass the default behavior, you can use methods like accordion.open(idx) triggered by the window's load event or other external functions.
I have been having trouble using an anchor tag as a trigger.
The use case for this is I have 5-10 frequently asked questions and i would like to have anchors to each question and also a mechanism to scroll to the correct question if the url contains a hash parameter.
In the past (using bootstrap3) this was possible and I simply return false or event.preventdefault on the anchor allow the accordion override the anchor functionality.
I have worked around it by wrapping my anchor with another div and using that as a trigger and using css to prevent clicks on anchor tag obscuring/intercepting the wrapping trigger event listener but this is not ideal.
Another issue I noticed is when I initialize the accordion to have a specific question open, via the openOnInit parameter, it does not fire the onOpen or beforeOpen event which I was relying on to begin the scroll down the page.
I have been able to work around both issues but it would be nice to have better support on those two features built in.
Thanks for your time and thanks for this great accordion script.
The text was updated successfully, but these errors were encountered: