JSEvals: Creates a list of keys whose values need to be evaluated on...

View source: R/utils.R

JSEvalsR Documentation

Creates a list of keys whose values need to be evaluated on the client-side

Description

It works by transforming list(foo = list(1, list(bar = I('function(){}')), 2)) to list("foo.2.bar"). Later on the JS side, the window.HTMLWidgets.evaluateStringMember function is called with the JSON object and the "foo.2.bar" string, which is split to ['foo', '2', 'bar'], and the string at that location is replaced in-situ with the results of evaluating it. Note '2' (character) should have been 2 (integer) but it does not seem to matter in JS: x[2] is the same as x['2'] when all child members of x are unnamed, and ('2' in x) will be true even if x is an array without names. This is a little hackish.

Usage

JSEvals(list)

Arguments

list

a list in which the elements that should be evaluated as JavaScript are to be identified

Details

This function is intended mostly for internal use. There's generally no need for widget authors or users to call it, as it's called automatically on the widget instance data during rendering. It's exported in case other packages want to add support for JS in contexts outside of widget payloads.

Author(s)

Yihui Xie


htmlwidgets documentation built on May 29, 2024, 9:35 a.m.