Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initializing manually a wet component added dynamically not working in pure JS/TS #9747

Open
joel-dev-qc opened this issue Mar 26, 2024 · 5 comments

Comments

@joel-dev-qc
Copy link

Required information

Describe the bug
I'm wondering if it's normal that I can't trigger the initialization manually using pure TS/JavaScript.
In JQuery you can do :

jQuery(table).trigger("wb-init.wb-tables");
// or 
jQuery(table).trigger("timerpoke.wb");

To Reproduce

const element = document.querySelector("yourSelector");

const event = new Event("timerpoke.wb", {bubbles: true});
element.dispatchEvent(event);

Expected behaviour
DispatchEvent should works but it's not.
Jquery works.

Additional information (optional)

Using the latest version of Wet with Typescript.

@mercury64
Copy link

Try CustomEvent rather than Event.

@joel-dev-qc
Copy link
Author

@mercury64 Yes, I'm pretty sure I tried too but it doesn't seems to work.

@joel-dev-qc
Copy link
Author

@mercury64 Ok I confirm that it doesn't work too.

Maybe @duboisp know if it's possible?

@mercury64
Copy link

mercury64 commented Apr 2, 2024

The following works:

  const element = document.getElementById('myTableID');
  const event = document.createEvent("Event");

  element.classList.add('wb-tables')

  event.initEvent("wb-init", true);
    // or
  event.initEvent("timerpoke", true);

  element.dispatchEvent(event);

@duboisp
Copy link
Member

duboisp commented Apr 3, 2024

JQuery event are triggered at the document level, not on the element. I am not sure that DOM event is fully compatible with JQuery event, I never tried.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants