Parsing Error: Unexpected Token

I’ve been reading on this from past posts but I just can’t figure out what is wrong with my code. I am fairly new to this type of coding, so I appreciate any help I can get! The error below is what shows for me:

Hi Carmen,

I’m noticing a couple things.

  1. Collapsed is a property that returns either true or false depending on whether or not the repeater is collapsed. It looks like you are trying to assign the data for the repeater, so you should be using data instead of collapsed in the code above.

  2. The onReady function for the page should stand alone at the top of the page just below any import statements or variable declarations. You have it inside a click event of an element (button?).

If you still have the same error after moving the onReady, it’s a result of there not being matching opening and closing braces and parenthesis in functions.

Hi Anthony, thank you for your response!

I’m afraid I am not understanding. The collapsed section was there because I wasn’t sure what to put there. Any suggestions? What I am trying to do is add a search bar with a button. Then eventually I want to add filters. I actually copied/pasted this code from this page: https://www.wix.com/corvid/forum/community-discussion/searching-a-database-displaying-in-repeater

So this is what the code looks like now. If I could just know what to replace “collpase” with and fix the red mark, I think it should be ok…I think. :thinking:

What Anthony is saying is that you can’t use ‘collapsed’ where you have.

Collapsed as Anthony as stated, means that the element is collapsed and not viewable on your page and is not taking up any room. It will not be seen unless you use the expand function.

See here for more detailed info on it.
https://www.wix.com/corvid/reference/$w.CollapsedMixin.html
https://www.wix.com/corvid/reference/$w.HiddenCollapsedMixin.html

Also, the tutorial that you are talking about in your post is using a table and defining the columns for that table.
https://support.wix.com/en/article/corvid-tutorial-adding-collection-data-search-functionality#filter-dropdown-options-distinctly

You should have a read of Wix API Reference and look at Table columns for which this code is written for.
https://www.wix.com/corvid/reference/$w.Table.html#columns

3. Define the table columns
Because your table isn’t connected to a dataset, you need to define the columns using the API for tables . You do this by defining a JSON object that lists the properties for each column and their values. The code is placed in the onReady function and looks like this:

$w.onReady(function () {    
    $w("#resultsTable").columns = [
      {
        "id": "col1",       // ID of the column for code purposes
        // The field key in the collection whose data this column displays  
        "dataPath": "field1", 
        "label": "Field 1", // The column header
        "width": 100,       // Column width
        "type": "string",   // Data type for the column
        // Path for the column if it contains a link  
        "linkPath": "link-field-or-property"  
      },
      {
        "id": "col2",
        "dataPath": "field2",
        "label": "Field 2",
        "visible": true,
        "type": "image",
        "linkPath": "link-field-or-property"
      } //,
      // more column objects here if necessary
      // ...
      // ...  
    }];

});

For example, the column definitions of a table that shows the results of a search on your recipes collection might look like this:

$w.onReady(function () {
 $w("#resultsTable").columns = [{
  "id": "col1",
  "dataPath": "title",
  "label": "Recipe",
  "type": "string",
 }, {
  "id": "col2",
  "dataPath": "course",
  "label": "Course",
  "type": "string",
 }, {
  "id": "col3",
  "dataPath": "meal",
  "label": "Meal",
  "type": "string",
 }];
});

In your post you are using a repeater - which is not a table - and therefore need to do what Anthony stated and use data.

Please see Repeater and data in the Wix API Reference for more detailed info on this.
https://www.wix.com/corvid/reference/$w.Repeater.html#data

With the parsing errors and again as Anthony stated, you need to make sure that you have matching pairs of parentheses and curly brackets in your code.

So you need to have equal numbers of open ( and closed ), as well as equal numbers of open { and }.

With your code, the first thing you could try is to simply delete the marked closed parentheses as it might just be that one making you have too many.

Or you may need additional parentheses or curly brackets which you can find out if go through your code and count your open and closed parentheses and make sure that you have matching pairs and an equal number at the end.

If you use the search function in the forum and simply search for parsing error, you will find many old posts all with the same issue.

Finally, please make sure that you post your code in a code block and not in an image as per the forum guidelines.

If you want others to help with your code used, then they are more likely to help a code block which they can simply copy and paste to check themselves in a blank site, rather than retype all the code in a provided screenshot.

Thank you