ui.R

The code runs as follows:

fluidPage( 
  # flexible layout function 
  h4(HTML("Think of a number:</br>Does Shiny or </br>JavaScript 
rule?")), sidebarLayout( sidebarPanel( # sidebar configuration sliderInput("pickNumber", "Pick a number", min = 1, max = 10, value = 5), tags$div(id = "output") # tags$XX for holding dropdown ), mainPanel( includeHTML("dropdownDepend.js"), # include JS file textOutput("randomNumber"), hr(), textOutput("theMessage") ) ) )

The use of h4(HTML("XXX")) allows us to shrink the title a little and add some HTML line breaks (avoiding HTML escaping with the HTML function as before). tags$div(...) produces a <div> element in which to place the drop-down menu, which JavaScript will build. The mainPanel() call just contains a reference to the JavaScript file that will run on the page, a place to put the random number the server will pick, a horizontal line, and a message from JavaScript regarding whether JavaScript or Shiny rules.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset