-
-
Save XD-DENG/1e31e690237794f45744 to your computer and use it in GitHub Desktop.
Shiny: Disable Button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
disableActionButton <- function(id,session) { | |
session$sendCustomMessage(type="jsCode", | |
list(code= paste("$('#",id,"').prop('disabled',true)" | |
,sep=""))) | |
} | |
shinyServer(function(input, output,session) { | |
observe({ | |
if(input$btn1 == 0) return() | |
disableActionButton("btn2",session) | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
shinyUI(basicPage( | |
tags$head(tags$script(HTML(' | |
Shiny.addCustomMessageHandler("jsCode", | |
function(message) { | |
console.log(message) | |
eval(message.code); | |
} | |
); | |
'))) | |
,actionButton("btn1","Disable the other button") | |
,actionButton("btn2","Button") | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment