-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
@storybook/html: Can't run JavaScript in story #4337
Comments
We are appending the html nodes into the DOM without any tools/libs (like jQuiery) that's why the script is not really evaluated. @Hypnosphi, WDYT about forcing evaluation in the render function? |
Yes, we use innerHTML which doesn't evaluate scripts. But you can rewrite the example like that:
There are still at least two problems with this, and forcing script evaluation wouldn't help with them. When you move to other story, event listener isn't removed. And when you move back to this story (or to another similar one), it isn't added to the freshly rendered instance of The most correct approach would be to use
If the
We probably should extract this from 'addon-actions` to allow arbitrary handlers, not just action loggers |
Thank you @Hypnosphi, but it seems to only work when I add a
|
Oh I see. You can use event delegation then:
|
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook! |
Possible bug
I'm trying out
@storybook/html
for the first time and have laid out a few components. A few of them need JavaScript to work properly, but I can't get the scripts to run.Bear in mind, this is vanilla ES5 Javascript, I'm not using web components of any kind. To add my components to the storybook, do as follows:
Even simple things as
console.log()
won't work, am I doing anything wrong?Versions
The text was updated successfully, but these errors were encountered: