Skip to content

Commit

Permalink
Fixes use with Interact in IJulia on page refresh
Browse files Browse the repository at this point in the history
See JuliaGizmos/Interact.jl#115 for more context
  • Loading branch information
JobJob committed Nov 1, 2016
1 parent 4793d9b commit 80c818c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/PlotlyJS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ 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_eval_comm = Ref(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,10 @@ end

typealias JupyterPlot SyncPlot{JupyterDisplay}

JupyterDisplay(p::Plot) = JupyterDisplay(p.divid, false, Condition())
JupyterDisplay(p::Plot) = begin
_ijulia_eval_comm[] = 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 +74,9 @@ end
# Helper functions #
# ---------------- #

_call_js(jd::JupyterDisplay, code) =
send_comm(_ijulia_eval_comm, Dict("code" => code))
_call_js(jd::JupyterDisplay, code) = begin
send_comm(_ijulia_eval_comm[], Dict("code" => code))
end

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

0 comments on commit 80c818c

Please sign in to comment.