The main documentation under [Writing Templates] the following example for binding an event handler with lit-html
is provided.
html`<button @click=${(e) => console.log('clicked')}>Click Me</button>`
Adding this a simple page with the default render
and html
functions imported and calling render however doesn't seem to render the button. If you remove the @click
event binding then the button is rendered. There must be something I'm missing or a serious bug in the library.
version: 0.10.2
The links below relate to how events handler bindings work in lit-html
:
on-click
is the only way to add an event listener. See relevant code snippet here. There's also a comment saying thatlit-extended
will be deprecated soon. I believe a lot oflit-html
's API will be changing until they release1.0.0
. – Anguine