Dear group,
I'm fairly new to the Shiny world and would like to know if the following problem is indeed a known limitation of Shiny Server or if there merely is a mistake in the source code.
Currently I'
struggling with the 'Shiny.addCustomMessageHandler' functionality. The problem is, that it
works well on the Firefox browser, however it does not work for any
other browser I've tried (Safari, IE10,9,8).
The CustomMessageHandler is supposed to
hide and show div boxes, e.g. the 'welcome_div' box, see below. This however, does not work on any other browser apart from the Firefox. For testing purposes I've tried to invoke
'alert' javascript messages instead of the 'hide=true' line, which as well worked fine on the Firefox,
but not any other browser. Hence the current assumption is, that the problem has something to do with the CustomMessage Handler.
Snipplet ui.r:
shinyUI(
navbarPage(...
tabPanel(
...
tags$head(
singleton(
includeScript("www/script.js")
)
),
)
...
div( id="welcome_div",
style ="margin-top:1%;background:#eee;fontSize:22;opacity:0.8;border-width:1px;border-style:solid;border-radius:10px;",
htmlOutput("welcome_text")
),
...
"script.js":
Shiny.addCustomMessageHandler("jsCode",
function(message) {
eval(message.value);
}
);
Snipplet server.r:
shinyServer(function(input, output, session) {
...
js_string <- sprintf('document.getElementById("welcome_div").hidden=true;')
session$sendCustomMessage(type='jsCode', list(value = js_string))
...
}
Thank you very much for your help