Q:

How do you call a javascript method on a htmlwidget (jsoneditor) in shiny?

I'm trying to use jsonedit from the listviewer package in a shiny app and want to display the tree fully expanded by default. There isn't an option to do this in the jsonedit() function, but the underlying javascript object has an .expandAll() method which should do it. How do I call this method from R shiny? My attempt below doesn't work either in a shiny app or directly in R.
library(shiny)
library(listviewer)
library(magrittr)
library(htmlwidgets)

x <- list(a=1,b=2,c=list(d=4,e='penguin'))

jsonedit(x, mode = 'view') %>% onRender("function(el,x,data) {this.expandAll();}")

shinyApp(
  ui = shinyUI(
    fluidPage(
      jsoneditOutput( "jsed" )
    )
  ),
  server = function(input, output){
    output$jsed <- renderJsonedit({
      jsonedit(x, mode = 'view') %>% onRender("function(el,x,data) {this.expandAll();}")
    })
  }
)

A:

jsonedit(x, mode = 'view') %>% 
  onRender("function(el,x,data) {this.editor.expandAll();}")

