Brilliant with HTML UI limited to Javascript OnLoad?

I am using R3.0.1 with Shiny0.7.0 to create a Shiny webpage with HTML UI.

I seem to have stumbled across what seems to be either a constraint or a mistake in Shiny regarding an OnLoad()element event body.

Since Shiny is not prepared for multiple HTML pages, as Joe Cheng stated here , I am trying to use jQueryinstead to show and hide divsif necessary.

This works pretty well, except if I hide the div in the OnLoad event . In this case, it seems that it is reactive input componentsno longer defined Shiny.

After that, you can see the test case:

Server.R

library(shiny)

shinyServer(function(input, output) {

    output$caption <- renderText({input$myInput})

})

index.html

<head>
    <script src="shared/jquery.js" type="text/javascript"></script> 
    <script src="shared/shiny.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/library.js"></script>    
</head>

 <body onload="initForm();"> 


    <div id="dMenu">

        <a href="#" onclick="showFoo();">Show foo div</a>
        <br>
        <a href="#" onclick="showBar();">Show bar div</a>
    </div>

    <!-- some random div -->
    <div id="foodiv">This is the Foo div</div>

    <!-- div with reactive input -->                
    <div id="bardiv">
        This is the Bar div
        <br>
        <input type="text" id="myInput" class ="shiny-bound-input" name="myInput" autocomplete="off"> 
        <div id="caption" class="shiny-text-output shiny-bound-output"></div>
    </div>

</body>

library.js

function showFoo(){
    $('#foodiv').show();    
    $('#bardiv').hide(); 
}


function showBar(){
    $('#foodiv').hide();
    $('#bardiv').show();    
}


function initForm(){
    /*showFoo();    */
}

, Shiny myInput caption. , , initForm(), , , myInput.

Firefox 23.0.1.

- , - ?

+4
1

Winston.

shinyServer(function(input, output) {
  output$caption <- renderText({input$myInput})
  outputOptions(output, 'caption', suspendWhenHidden=FALSE)
})

, - .

+6

All Articles