You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm very new to Stipple and Genie so maybe I'm doing something terribly wrong 😄
I have the following code:
using Stipple
using StippleUI
@reactive!mutable struct SBModel <:ReactiveModel
clicks::R{Int}=0
value::R{Int}=0
dict::R{Dict}=Dict{String, Any}("first"=> value, "second"=>Dict("inner"=>1))
html::R{String}=render(dict)
endfunctionrender(i::Int, keychain="dict")
input("", placeholder="$i", @bind(keychain, "number"))
endfunctionrender(p::Pair, keychain="dict")
k ="$(keychain).$(p.first)"returnspan([p(p.first), render(p.second, k)])
endfunctionrender(d::Dict, keychain="dict")
list = []
for v in d
k ="$(keychain).$(v.first)"push!(list, [p(v.first), render(v.second, k)])
endreturnul(list)
endfunctionhandler(model)
on(model.value) do (_...)
d = model.dict[]
d["first"] = model.value[]
# adding a new key
d["help"] =1
model.dict[] = d
println("model.value: ", model.value[])
model.html[] =render(d)
endon(model.dict) do (_...)
@show model.dict[]
end
model
endfunctionui(model::SBModel)
[
page(model,
class ="container",
title ="Buttons demo",
[
heading("Buttons")
row(
[
cell([btn("Less! ", @click("value -= 1"))])
cell(
[
span(var"v-html"="html")
],
)
cell([btn("More! ", @click("value += 1"))])
],
)
],
),
]
endroute("/") do
model = SBModel |> init |> handler
ui(model) |> html
endup(rand((8000:9000)), open_browser =true)
based on the StippleDemo button example.
Now when I change on a button the new "help" part is rendered as well so the model.html is reactive and everything works fine.
Though when I change the value in an input field now it doesn't call the on(model.dict) method.
If I change span(var"v-html"="html") to model.html[] then the @bind works but it isn't reactive on the html anymore so I can't add the help.
Is this in any way reasonable or should I do something very different?
Thanks in advance!
The text was updated successfully, but these errors were encountered:
I'm very new to Stipple and Genie so maybe I'm doing something terribly wrong 😄
I have the following code:
based on the StippleDemo button example.
Now when I change on a button the new "help" part is rendered as well so the model.html is reactive and everything works fine.
Though when I change the value in an input field now it doesn't call the
on(model.dict)
method.If I change
span(var"v-html"="html")
tomodel.html[]
then the@bind
works but it isn't reactive on thehtml
anymore so I can't add thehelp
.Is this in any way reasonable or should I do something very different?
Thanks in advance!
The text was updated successfully, but these errors were encountered: