How to update button labels in R Shiny?

后端 未结 4 1889
独厮守ぢ
独厮守ぢ 2021-01-20 00:10

The R Shiny website has a great example of how to update the labels and values of a variety of input types based on user input. However, I couldn\'t find anything for butto

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-20 01:06

    If your button is already built, the solution is to use library "shinyjs".

    library(shinyjs)
     # in UI section
    shinyjs::useShinyjs()
     # in Server section: call this function at any time to update the button label
    runjs(paste0("$('label[for=\"YourButtonId\"]').text('",TextVariable,"')"))
    

提交回复
热议问题