Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdding click events to dom that was added via m.trust #2569
Labels
Projects
Comments
Could you maybe just keep the events at a higher level, like the element that contains the |
You can use a fragment with an m.render(document.body, m.fragment({
oncreate({dom}){dom.onclick = () => console.log('clicked')}
}, [
m.trust('<h1>Hi, click me')
])) |
You might also want to consider just using |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mithril version:
2.0.0-rc.9
Browser and OS:
Electron 8.0.0 (Chrome), macOS Sierra
Project:
https://github.com/ExamProCo/fast-author
Code
// Code
Context
I am creating a markdown editor.
I am attempting to make it so that when I click an image in the preview I can process images eg. add a border, crop or etc.
So I render out my markdown and I use
trust
so I its can safely render.I need to make it so I can fire click events on the images.
I am thinking I can use
onupdate(vnode)
, however I'm not sure how I would select the elements and bind click events by doingvnode.dom
to all img elements contained within.I can use
document.querySelectorAll('.preview img')
and attempt to bind click events through listeners but I imagine this is not a great idea since I would think those event listeners would become invalid on a redraw.What is the mithril way for binding events that are from dynamic html?