0

I'm writing some input bindings in Shiny, and want to build my functions into a package. The problem now is input bindings requires javascript code which is usually located in the www directory in the application directory, so the user need to copy the javascript file into his/her www every application he/she requires the package and use the input bindings.

And I want when the user of this package require()ed this package, the corresponding input binding jQuery definitions are automatically loaded with the app just as the native binding definitions are. Or does anyone knows other solutions for this situation.

Lytze
  • 755
  • 6
  • 12

1 Answers1

1

You can place the javascript code in the inst folder in your package and declare that folder as a dependency. There are probably other ways, perhaps even better ways, but you can see as an example how I did this in my package. I created a colourInput widget that needed two javascript files: one for the input bindings, and one for the actual javascript library for the button.

Here is the folder where my javascript and css is kept (notice how it's under inst/www/shared/colourpicker), and here is the code I use to declare the javascript/css files as dependencies, and at the last line I attach the javascript/css dependencies to the button HTML.

It took me a while to understand how to implement this, but this is a working example, so you can look at this real code and follow a similar approach.

DeanAttali
  • 25,268
  • 10
  • 92
  • 118