Skip to content

Commit b87c8a0

Browse files
authored
back to using numericValue (#131)
1 parent 1f0fbf0 commit b87c8a0

File tree

1 file changed

+3
-30
lines changed

1 file changed

+3
-30
lines changed

src/input.jl

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -158,42 +158,15 @@ function input(::WidgetTheme, o; extra_js=js"", extra_obs=[], label=nothing, typ
158158
(o isa AbstractObservable) || (o = Observable(o))
159159
(changes isa AbstractObservable) || (changes = Observable(changes))
160160
data = Pair{String, Any}["changes" => changes, bindto => o]
161-
if isnumeric
162-
bindtoString = bindto*"String"
163-
oString = Observable(string(something(o[], "")))
164-
push!(data, bindtoString => oString)
165-
string_js = js"""
166-
var obs = this.$(WebIO.JSString(bindto));
167-
var obsString = this.$(WebIO.JSString(bindtoString));
168-
obsString.subscribe(function(value) {
169-
var val = parseFloat(value);
170-
if (!isNaN(val)) {
171-
obs(val);
172-
}
173-
})
174-
obs.subscribe(function(value) {
175-
var str = JSON.stringify(value);
176-
if ((str == "0") && (["-0", "-0."].indexOf(obsString()) >= 0))
177-
return;
178-
if (["null", ""].indexOf(str) >= 0)
179-
return;
180-
obsString(str);
181-
})
182-
"""
183-
extra_js = js"""
184-
$string_js
185-
$extra_js
186-
"""
187-
else
188-
bindtoString = bindto
189-
oString = o
161+
if isnumeric && bind == "value"
162+
bind = "numericValue"
190163
end
191164
append!(data, (string(key) => val for (key, val) in extra_obs))
192165
countChanges = js_lambda("this.changes(this.changes()+1)")
193166
attrDict = merge(
194167
attributes,
195168
Dict(:type => typ,
196-
Symbol("data-bind") => "$bind: $bindtoString, valueUpdate: '$valueUpdate', event: {change: $countChanges}"
169+
Symbol("data-bind") => "$bind: $bindto, valueUpdate: '$valueUpdate', event: {change: $countChanges}"
197170
)
198171
)
199172
className = mergeclasses(getclass(:input, wdgtyp), className)

0 commit comments

Comments
 (0)