OK. Manage to hack it.
I add one more line in the click() function in simpleNetwork.js to send Shiny.onInputChange back to Shiny. The click() is now something like this:
// click event handler
function click(d) {
d3.select(this).select("text").transition()
.duration(750)
.attr("x", 22)
.style("stroke-width", ".5px")
.style("opacity", 1)
.style("fill", x.options.nodeClickColour)
.style("font", x.options.clickTextSize + "px serif");
d3.select(this).select("circle").transition()
.duration(750)
.style("fill", x.options.nodeClickColour)
.attr("r", 16);
Shiny.onInputChange(
el.id+"_clickednode",
d.name); ## added line to send onInputChange back to Shiny.
}
Let me know if there is a more elegant way. :)
Cheers,
JS