Reputation: 245
I have a SvelteKit app with an @error.svelte
page at the root of the /routes
folder. Inside of this page, I have two buttons. One is in the header and the other one trigger's a page event when clicked on. For some reason, neither of these buttons are triggering the on:click
handler when clicked on.
Here is the simplified code
<script>
import Button, { Label } from '@smui/button';
function handleClick() { // Neither the smui button or the native html button run this function
console.log('click');
}
</script>
<div class="page-container">
<Button
variant="unelevated"
on:click={handleClick}> <!--Nothing happens when clicked!-->
<Label>Go Back To Homepage</Label>
</Button>
<button on:click={handleClick}>Click me</button> <!--Nothing happens when clicked!-->
</div>
I have tried the following troubleshooting steps:
on:click
to see if it's being called: The function isn't being called at all.on:click
handler. This one didn't call the click function either.@error.svelte
located at the root
of my /routes
folder but I couldn't understand the answer that well.
Assuming this answer is true, the problem would have been fixed in the native HTML button. But it wasn't.Any clue?
Upvotes: 0
Views: 308
Reputation: 245
I've fixed my error by addressing an unrelated issue that was showing up in my console. Click events were being disabled due to this error
Upvotes: 0