Parsing error: Unexpected token )

Hi all,

I am new to the Dev Mode within Wix, but thought I would explore it. I have followed one of Corvid by Wix tutorials for creating a read more link. I have followed each step, and have added the code at the end as per suggested. However, I am getting the following error message ‘Parsing error: unexpected token )’ regarding the last few symbols at the bottom. The code is as follows, can someone please advise.

$w.onReady( function () {
$w( “#ReadMoreButton” ).onClick(() => {
$w( “#readMoreStatebox” ).changeState( “expandedState” );
});

$w( “#ReadLessButton” ).onClick(() => {
$w( “#readMoreStatebox” ).changeState( “collapsedState” );
{);

Surely, change your last bit of code to →

$w.onReady(function () {
 $w("#ReadMoreButton").onClick(() => {    
  $w("#readMoreStatebox").changeState("expandedState");
 });
 $w("#ReadLessButton").onClick(() => {    
  $w("#readMoreStatebox").changeState("collapsedState");
 });
});

Brilliant, thank you! It worked!! However, upon testing, it expands, but it does not collapse. Have I missed something within the coding?

@harleyweber Is " collapsedState " your multi-state box’s collapsed state Id ???

@ajithkrr Yes, it is. Now when I preview it, and I click to collapse, I get the following message

Wix code SDK error: The “stateInfo” parameter that is passed to the “changeState” method cannot be set to the value collapsedState. It must be a state or a state ID from the “comp-khoq0mmq” state box

The “stateInfo” parameter that is passed to the “changeState” method cannot be set to the value collapsedState. It must be a state or a state ID from the “ReadMoreStateBox” state box

@ajithkrr Update, there was a error with one ID with a capital letter. It now works. Thank you for your help and time though. Going forwards, can I copy and paste this state box and its code to repeat throughout this page and the site?

@harleyweber No You can’t…
(Kidding)
Sure !! You can !!!

Good Luck Coding !!:wink: