JavaScript

Lastly, let's look at the JavaScript. As previously mentioned, shinyjs.buttonClick is a function that can access the arguments of js$buttonClick(). With that in mind, let's look at the code:

shinyjs.buttonClick = function(params) {  // boilerplate code  var defaultParams = {    color : "black",    size : "medium"  };  params = shinyjs.getParams(params, defaultParams);   // rest of code  var elem = document.getElementById('selection');   elem.innerHTML = document.getElementById('year').value;   elem.style.color = params.color;   elem.style.fontSize = params.size;}

Note that it is not necessary to include the <script type="text/javascript">...</script> script tag around the JavaScript in this file. The first part is boilerplate code, and it's designed ...

Get Web Application Development with R Using Shiny - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.