| onRender {htmlwidgets} | R Documentation |
Use this function to supplement the widget's built-in JavaScript rendering logic with additional custom JavaScript code, just for this specific widget object.
onRender(x, jsCode)
x |
An HTML Widget object |
jsCode |
Character vector containing JavaScript code (see Details) |
The jsCode parameter must be a valid JavaScript expression
that returns a function.
The function will be invoked with two arguments: the first is the widget's
main HTML element, and the second is the data to be rendered (the x
parameter in createWidget). When the function is invoked, the
this will be the widget instance object.
The modified widget object
onStaticRenderComplete, for writing custom JavaScript
that involves multiple widgets.
## Not run:
library(leaflet)
leaflet() %>% addTiles() %>%
onRender("
function(el, x) {
// Navigate the map to the user's location
this.locate({setView: true});
}
")
## End(Not run)