Closed mathieuleclaire closed 3 years ago
Well, It is not what I want to do. I would like to trigger a SnackBar element from an action triggered any time (like a button click) and not at the mount time. I don't know how to call the relevant methods from an already built snack bar element. Note that it could be the same with a dialog we want to trigger from a button click.
@mathieuleclaire ctx.thisNode
is the Laminar element, i.e. the same instance as the result of Slider()
in the linked example (see Slider.scala). However, Slider.apply
return type is, incorrectly, a generic HtmlElement
, whereas it should actually be the more specific El
.
Same for the SnackBar
component, its apply method return type should be El
. Then you'll be able to say something like:
val snackbar = Snackbar(...)
div(
"Hello",
snackbar, // add a snackbar in the DOM
button(
"Show",
onClick --> (_ => snackbar.ref.show()) // call this whenever
)
)
Well, when this ref
call is done outside a onMountCallback
, it returns a wrong type, so that the show()
method does not exist. Here is the error I get:
value show is not a member of org.scalajs.dom.html.Element
[error] snackbar.ref.show()
Yes, that's exactly what I'm saying.
Snackbar.apply return type needs to be changed from HtmlElement
to El
. Just the type signature, the content of the method is ok. Then it will work.
Looks like a bug in the generator - I will change this issue to that. Easy fix here.
Fixed by 62c203bff63570d0c516efc95dce3e9727e013ec
Excellent. Sorry, I was focusing on Laminar, to learn it before fixing issues in this project.
Hi, I can't find how trigger the
show()
function of a SnackBar component or a Dialog.Thanks !