Even after following the directions I keep getting this error message: Error parsing web-module ‘public/pages/y1ynz.js’: Unexpected token (4:33) while parsing file: public/pages/y1ynz.js
Here is my code and a picture of the error message if anyone can take a look and help me out
The code works fine if you follow the tutorial and check your code as Shan has already mentioned and made sure that you added the missing opening parentheses on the onClick event lines.
The code should be as this if going from the tutorial itself.
The issue you have got with the not a function error is most probably due to the fact that the tutorial uses #readLessButton on the collapse button code.
$w("#readLessButton").onClick(() => {
Whereas you are using #readLessButton1 in your own code, which has the added ‘1’ at the end of it.
$w("#readLessButton1").onClick(() => {
So you would need to double check that buttons id name and make sure that the code and the button id is exactly the same and not different.
If they are different, then that is why you are getting the error as there is no button element on your page with the id name of #readLessButton1.
Hello! Thank you for the help so i changed the button name back to readLessButton but the error in my code seems to be with line 2 and is saying ‘#readmoreButton’ is not a valid selector. I’ve double checked that the button id names exactly match the code so I am still confused as to why it won’t run. Let me know if you have any idea
Where are you placing the code? Is it in the page code tab or the site code tab?
If it is in the site code tab, then it is probably just an ongoing issue with the site code tab where it shows an error, however if you actually test it on a live site it all works fine.
If everything is set up correctly and it still does not want to work for you then simply try changing the buttons onClick function from full code to adding the onClick event through the properties panel and change the function to the new export function line instead.
So basically click on the button for each read more and read less buttons and click on the onClick event in the properties panel for it - if the properties panel is not showing simply right click on the button element and go to view properties.
This will add a new line of export function… at the bottom of your current code, so you simply need to take that top line and replace the existing onClick function line with it.
Do the same for both buttons and you will need move this out of the pages onReady function and to add a closing parentheses and curly bracket after the onReady function, as well as removing the parentheses from after each export function line too.
I have similar problem. When I do preview, my multi state boxes ( expendind read more box ) doesnt work. The code gives an error msg " Property ‘changeState’ does not exist on type ‘State’. “”