zakky
zakky

Reputation: 33

how do i get data that is input by javascript in shiny?

i trying to make a input text box that is input by javascript. Input is ok in ui.r, but at that time i can not get the input data from server.R. Below is my code.

-- ui.r  
tags$script(src="datetimepicker_css.js"),  
textInput(inputId = "sDate", label = "start date"),      
tags$img(src="cal.gif", onclick="javascript:NewCssCal('sDate','yyyyMMdd','dropdown',true,'24')", style="cursor:pointer")

-- server.r     
date <- reactive({
        getDate <- input$sDate     
            getDate       
})

When i input the date using javascript, but getDate has no data. (There is a calendar icon. When i click it, it shows a calendar. And i can select the date and time) When i input the date using keyboard, and getDate has data. (In this case, i just click the text box directly, and i input the date and time)

Upvotes: 1

Views: 317

Answers (1)

zakky
zakky

Reputation: 33

Shiny.unbindAll(), Shiny.bindAll() is very useful function. I just add these functions, then this problem was fixed.

// .js file

 function keydown()       
 {          
    Shiny.unbindAll()
     .......
    Shiny.bindAll()
 }

Thanks.

Upvotes: 1

Related Questions