👀 Reading hidden code
slider = html"<input type='range'>"
Experiment 1
👀 Reading hidden code
Uncomment:
👀 Reading hidden code
👀 Reading hidden code
# md"""Last value of $(@bind x slider) was $(x)"""
Oh oh... it's stuck in an infinite loop! Why this happens is not important right now, but notice that the value is always missing, even in the second iteration.
👀 Reading hidden code
👀 Reading hidden code
Enter cell code...
We create our own slider so that observable/stdlib doesn't send the initial value.
👀 Reading hidden code
👀 Reading hidden code
slider_without_initial = html"""
<span>
<input type='range'>
<script>
const span = this.currentScript.parentElement
const input = span.querySelector("input")
input.oninput = (e) => {
span.value = input.value
span.dispatchEvent(new CustomEvent("input"))
e.stopPropagation()
}
</script>
</span>
""";
This cell depends on z
, so it will run when z
is set.
z
is set to the new value before the cell is executed (by the @bind
system), but not when the cell is first run (the bond doesn't exist yet, so z
is just an undefined variable).
👀 Reading hidden code
Last value of
begin
local wow = missing
try wow = z catch end
output = md"""Last value of $(@bind z slider_without_initial) was $(wow)"""
end
👀 Reading hidden code
👀 Reading hidden code