Skip to content

Commit

Permalink
Merge pull request #13 from JuliaGizmos/pv/render
Browse files Browse the repository at this point in the history
do not hardcode observable value in onimport
  • Loading branch information
piever committed Mar 29, 2019
2 parents db75986 + f65a0af commit 1dd7097
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Knockout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ function knockout(template, data=Dict(), extra_js = js""; computed = [], methods
for (k, v) in data
skey = string(k)
(v isa ObservablePair) && (v = v.second)
ko_data[skey] = isa(v, AbstractObservable) ? v[] : v
if isa(v, AbstractObservable)
# associate the observable with the widget
setobservable!(widget, skey, v)
Expand All @@ -54,6 +53,9 @@ function knockout(template, data=Dict(), extra_js = js""; computed = [], methods
end
this.valueFromJulia[$skey] = false
end, self)
ko_data[skey] = @js $v[]
else
ko_data[skey] = v
end
end

Expand All @@ -69,8 +71,6 @@ function knockout(template, data=Dict(), extra_js = js""; computed = [], methods
computed_dict[skey] = @js this[$skey] = ko.computed($f, this)
end

json_data = JSON.json(ko_data)

on_import = js"""
function (ko, koPunches) {
ko.punches.enableAll();
Expand All @@ -94,7 +94,7 @@ function knockout(template, data=Dict(), extra_js = js""; computed = [], methods
ko.applyBindingsToNode(element, { value: stringified, valueUpdate: allBindings.get('valueUpdate')}, context);
}
};
var json_data = JSON.parse($json_data);
var json_data = $ko_data;
var self = this;
function AppViewModel() {
for (var key in json_data) {
Expand Down

0 comments on commit 1dd7097

Please sign in to comment.