Collapse Group Wix SDK Error

Hi, I’m trying to get a collapsed group to expand when I click a button. The code seems pretty straightforward but I get an error when it runs and I’m not so sure what I’m doing wrong.

$w.onReady(function () {
  $w("#group1").collapse();
  $w("#button3").onClick(
    $w("#group1").expand()
  )
 }

Btw I have a lot of other code I am just showing the relevant part. The error line is the “$w(”#button3").onClick(" line. Anyways I’d love if this could be explained because I’m very confused.

Wix code SDK error: The onClick parameter that is passed to the onClick method cannot be set to the value [object Promise]. It must be of type function.

Hi Yann,
Yes, your $w(“#button3”).onClick ( line is wrong. Look at this documentation page:
https://www.wix.com/corvid/new-reference/$w/button/onclick
That should solve your problem.
~Hope this helps!~
Arthur :grin: