I have written a fairly straight forward module, consisting of a textInput on the client and a server function that updates the value of that textInput. To accomplish this, I call updateTextInput() in the server function. However, the textInput on the client is NOT updated.
What should I do to have my module server function update the textInput on the client?
Here is a simplified version of my code:
global.R with module definition
# Client side.
specifyInput <- function(id, points){
ns <- NS(id)
tagList(textInput(ns('points'), label='Total', value=points))
}
# Server side.
specify <- function(input, output, session){
ns <- session$ns
observe({
new.value = 2 * as.numeric(input$points)
#this line does not seem to work
updateTextInput(session, ns('points'), value = new.value)
})
# create dataframe with entered value
df <- reactive(data.frame(points = as.numeric(input$points)))
# return the dataframe
return(df())
}
ui.R
specifyInput("ttlEntry", 10)
server.R
function(input, output, session){
test <- reactive(callModule(specify, "ttlEntry"))
#somewhere in the code, call test()
}
In reality, I want to attach a .5 behind the entered value when the user enters a period, for example if user enters "10." then the textInput is updated to display "10.5" However for testing purposes, I have changed that code to new.value = 2 * ...
Any help is greatly appreciated.