As it was mentioned earlier, one of the biggest advantages of customizing the application UI by just adding tags to UI.R
becomes even more visible when the user interface elements (HTML, JavaScript, and so on) depend on reactive values too. This case of reactivity is definitely different from the ones seen so far as the output should be included as HTML code, especially when it comes to JavaScript. For this kind of situation, session$sendCustomMessage()
along with a built-in JavaScript function, Shiny.addCustomMessageHandler()
, have to be used.
Basically, the first function sends a message to the user interface that will be based on reactive inputs. The second function listens to this and acts accordingly. Considering the JavaScript example again, the following code produces an application where if the input variable (input$number
) is less than or equal to 25
, the mouseover
/mouseout
colors will be blue
or gray
respectively, while if the input value is...