Using {golem} js functions

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Using {golem} js functions

{golem} comes with a series of JavaScript functions that you can call from the server. These functions are added by default with bundle_resources() .

Then they are called with golem::invoke_js("fonction", "ui_element").

This ui_element define the UI element to interact with. It can be a full jQuery selector, an id or a class. Note that you can add several elements and iterate other them.

invoke_js can be used with any function defined in a JavaScript Custom Handler, that you can build with golem::add_js_handler().

golem::invoke_js()

golem::invoke_js("showid", ns("plot"))
golem::invoke_js("showhref", "panel2")

See ?golem::activate_js() for the full list.

A quick intro to jQuery selectors

Note that in html, tags contains attributes. For example:

<a href = "https://thinkr.fr" data-value = "panel2">ThinkR</a>

contains href & data-value. You can refer to these attributes with [] after the tag name.



Try the golem package in your browser

Any scripts or data that you put into this service are public.

golem documentation built on April 17, 2021, 9:06 a.m.