How can I use external buttons to open or close an accordion?

Hi Team,

I’m Darshan Hiranandani, working on a feature where I want to toggle an accordion by clicking on an external button. Here’s the situation:

  • Current Approach: I’ve tried using brx-open directly, but it only works until the accordion’s built-in toggle is interacted with, after which the external button stops functioning. Additionally, this method doesn’t play the accordion opening animation controlled by Bricks.
  • Issue with JS Click Function: The JavaScript click function I’ve tried doesn’t seem to work for toggling the accordion.

Given these issues, I’m looking for a proper approach to achieve this functionality. Could anyone provide suggestions or guidance on the following?

  1. External Button Toggle: What’s the best way to toggle an accordion using an external button while maintaining the animation?
  2. JavaScript Approach: How can I properly use JavaScript to control the open/close state of an accordion with external buttons?
  3. Integrating with Bricks: How can I ensure that the accordion’s animation and behavior are correctly triggered by external buttons?
  4. Event Handling: What is the recommended method for handling events to toggle the accordion from an external button?
  5. Alternative Methods: Are there alternative methods or best practices for achieving external button control over an accordion?

Your insights or suggestions on resolving this issue would be greatly appreciated!

Thanks,

Darshan Hiranandani

Did you find a solution? I am in the same situation now…

I’m pretty sure it’s a bot/AI user. Look at the post history.

  • stock image as profile image
  • starts every post with ‘I’m Darshan Hiranandani’ and full name in post title.
  • never replies
  • a google search shows the same posts being written in multiple forums, just with minor word changes for the specific topic.
  • writes like a chatbot.

1 Like

Hmmm… What a boring hobby…!