Skip to main content
Nov 17, 2023 1:23 PM UTC
Solved

SolidJS - Button onClick not working

Hello, 
can someone advice if I handle onClick with vanilla js is working but if I use the onclick with Solidjs is not working.
I do not get any errors:

 

 

import { JSX, createSignal } from 'solid-js';

import { render } from 'solid-js/web';




const App = (): JSX.Element => {

 

  document.addEventListener('DOMContentLoaded', function () {

    const button = document.getElementById('myButton') as HTMLButtonElement;

    button.addEventListener('click', function () {

      console.log('Experiment C - vanilla js');

    });

  });

  return (

    <>

      <button
        id="myButton"
        style={{ 'z-index': 3000, background: 'red' }}
      >

        click -JS
   
 
</button>
<button

        class="bttn-solid"

        style={{ 'z-index': 3000, background: 'red' }}

        onClick={() => console.log('Experiment C ')}

      >

        click me-Solid

      </button>


    </>

     

  );

};






 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
sSimonaAccepted solution
Nov 30, 2023 8:48 AM UTC

All good now

The issue was in the bundler

3 replies

alexbishop
Adobe Employee
Adobe Employee
Nov 21, 2023 2:19 PM UTC

Where is it that you're trying to use that code?

Translate
sSimonaAuthorAccepted solution
Nov 30, 2023 8:48 AM UTC

All good now

The issue was in the bundler

Translate
May 7, 2024 6:19 AM UTC

Hello,

 Hope this message finds you well

I just want to know how we connect AEM with soldJs.  

Translate