I have this code in Stipple:
import Stipple
import StippleUI
import Genie
@Stipple.vars reactives begin
name::String = "World!"
end
Stipple.Layout.add_script("https://cdn.jsdelivr.net/npm/sweetalert2@11")
############ javascript code (PROBLEM) ############
lib_module() = [
Stipple.script(type ="module", "
// script code goes here
document.getElementsByClassName('btn1')[0].addEventListener('click', function() {
Swal.fire({title: 'Stipple Fire!'})
})
")
]
@Stipple.deps lib_module
############ javascript code (PROBLEM) ############
function ui()
finalMatch = """
<button class="btn1">Click me!</button>
<q-input v-model="name"/>
<p>Typed text: {{ name }}</p>
"""
return finalMatch
end
Stipple.route("/") do
Stipple.page(
Stipple.init(reactives),
ui()
) |> Stipple.html
end
Stipple.up()
But Sweet Alert's javascript doesn't work. I don't know what I did wrong, I followed the steps in the documentation, but I don't think I did something right.
I could do it like this, with onclick in the button tag:
<button class="btn1" onclick="Swal.fire({title: 'Stipple Fire!'})">Click me!</button>
But I would like to access the script normally.
I have this code in Stipple:
But Sweet Alert's javascript doesn't work. I don't know what I did wrong, I followed the steps in the documentation, but I don't think I did something right.
I could do it like this, with onclick in the button tag:
But I would like to access the script normally.