Problem with onClick() event

I have one box and this code:

import wixLocation from 'wix-location';

export function box7_click(event) {
wixLocation.to("/Timer"); 
}

Until a few days ago everything worked perfectly, now it doesn’t work anymore, can someone help me?
Thank you

I assume that you are using a dynamic dataset. Did you some changes in your collection in the last period of time?

Hi,
no changes. I use that function without dataset, I need it because I have a box that, when clicked, must redirect to a page.

Try this one…

$w.onReady(function () {
	$w('#box7').onClick(()=>{
		wixLocation.to("/Timer");
	});
});

Does it work now?

If not, do you get any errors in the console?

@russian-dima Nothing… If I go with the mouse on the writing “event” it appears “(parameter) event : any” (image attached)

@bertolinoand
Did you change your code, which i gave to in my last post?
Delete your export function and paste my code shown above (paste it into the onReady-code-part).

…delete your old one…

import wixLocation from 'wix-location';

export function box7_click(event) {console.log("Clicked")
    wixLocation.to("/Timer"); 
}

… & paste this one… (into the onReady-section)

$w.onReady(function(){
    $w('#box7').onClick(()=>{console.log("Clicked")
        wixLocation.to("/Timer");
    });
});

Take a look into —> CONSOLE! Did you get any message?

You can also do the same with your old code. Do you get any message ?

Why changing the code?
Because i assume that the connection between CODE and PROPERTY-PANEL is broken somehow.

Take a look here to get more info about PROPERTY-PANEL…

@russian-dima In both cases there is “Clicked” :disappointed_relieved: OMG

@bertolinoand
The connection exists in both cases.
Now ask yourself what could be else wrong?

1 Like

@russian-dima At this point the only problem is the function “wixLocation . to”

Thanks I found the solution, there was an “unsupported-link-type” problem!

This is the way how to find issues and bugs —> always use —> console.log() :wink: