Skip to content

Commit

Permalink
Fixes Interact in IJulia on page refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
JobJob committed Nov 1, 2016
1 parent 4793d9b commit d2bf644
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/PlotlyJS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ function __init__()
end

# set up the comms we will use to send js messages to be executed
global const _ijulia_eval_comm = Comm(:plotlyjs_eval)
global const _ijulia_return_comms = ObjectIdDict()

@eval begin
Expand Down
10 changes: 7 additions & 3 deletions src/displays/ijulia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ end

typealias JupyterPlot SyncPlot{JupyterDisplay}

JupyterDisplay(p::Plot) = JupyterDisplay(p.divid, false, Condition())

const divid2comm = Dict{Base.Random.UUID, Any}()
JupyterDisplay(p::Plot) = begin
divid2comm[p.divid] = Comm(:plotlyjs_eval)
JupyterDisplay(p.divid, false, Condition())
end
JupyterPlot(p::Plot) = JupyterPlot(p, JupyterDisplay(p))

fork(jp::JupyterPlot) = JupyterPlot(fork(jp.plot))
Expand Down Expand Up @@ -71,8 +76,7 @@ end
# Helper functions #
# ---------------- #

_call_js(jd::JupyterDisplay, code) =
send_comm(_ijulia_eval_comm, Dict("code" => code))
_call_js(jd::JupyterDisplay, code) = send_comm(divid2comm[jd.divid], Dict("code" => code))

## API Methods for JupyterDisplay
_the_div_js(jd::JupyterDisplay) = "document.getElementById('$(jd.divid)')"
Expand Down

0 comments on commit d2bf644

Please sign in to comment.