Use this function to supplement the widget's built-in JavaScript rendering
logic with additional custom JavaScript code, just for this specific widget
object.
Usage
onRender(x, jsCode)
Arguments
x
An HTML Widget object
jsCode
Character vector containing JavaScript code (see Details)
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.
Value
The modified widget object
See Also
onStaticRenderComplete, for writing custom JavaScript
that involves multiple widgets.
Examples
## 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)