admin管理员组文章数量:1415120
I have another problem with my shiny app. The goal is to disable some inputs in my app when the user presses an actionButton. I found this solution, which works fine for the textinputs and the numeric inputs, but oddly not for selectinput or selectizeinput. I know the solution contains somehow using javascript, but I don't know how.
Thanks in advance for the help!
Edit:
Perhaps I haven't made it clear enough. Sorry guys! I'll add the necessary code chunks.
This is the disablefunction from the link. It works fine with actionButtons and numeric Inputs, but not with select or selectize Input.
disableActionButton <- function(id,session) {
session$sendCustomMessage(type="jsCode",
list(code= paste("$('#",id,"').prop('disabled',true)"
,sep="")))
disableselectButton <- function(id,session) {
session$sendCustomMessage(type="jsCode",
list(code= paste("$('#",id,"').prop('select',false)"
,sep="")))
disableselectButton <- function(id,session) {
session$sendCustomMessage(type="jsCode",
list(code= paste("$('#",id,"').prop('hide',false)"
,sep="")))
This is an example of the Inputs which don't get disabled. As I said the solution lies, probably, in javascript, but I don't even know the fundamentals to be honest. I've tried different probs like hide=true oder select=false, which didn't work (you can see the functions that did not work above as well).
selectInput("algorithmicMethod1",
label=h5("Berechnungsalgorithmus erster Wahl"),
c("RoT","Pickands"),
selected="RoT"),
conditionalPanel(condition="input.algorithmicMethod1 =='RoT'",
selectInput("algorithmicMethod2",
label=h5("Berechnungsalgorithmus zweiter Wahl"),
"Pickands",
selected="Pickands")),
conditionalPanel(condition="input.algorithmicMethod1 =='Pickands'",
selectInput("algorithmicMethod2",
label=h5("Berechnungsalgorithmus zweiter Wahl"),
"RoT",
selected="RoT"))
So, is there any other way to disable the select/selectize-Inputs?
Thanks again.:)
I have another problem with my shiny app. The goal is to disable some inputs in my app when the user presses an actionButton. I found this solution, which works fine for the textinputs and the numeric inputs, but oddly not for selectinput or selectizeinput. I know the solution contains somehow using javascript, but I don't know how.
Thanks in advance for the help!
Edit:
Perhaps I haven't made it clear enough. Sorry guys! I'll add the necessary code chunks.
This is the disablefunction from the link. It works fine with actionButtons and numeric Inputs, but not with select or selectize Input.
disableActionButton <- function(id,session) {
session$sendCustomMessage(type="jsCode",
list(code= paste("$('#",id,"').prop('disabled',true)"
,sep="")))
disableselectButton <- function(id,session) {
session$sendCustomMessage(type="jsCode",
list(code= paste("$('#",id,"').prop('select',false)"
,sep="")))
disableselectButton <- function(id,session) {
session$sendCustomMessage(type="jsCode",
list(code= paste("$('#",id,"').prop('hide',false)"
,sep="")))
This is an example of the Inputs which don't get disabled. As I said the solution lies, probably, in javascript, but I don't even know the fundamentals to be honest. I've tried different probs like hide=true oder select=false, which didn't work (you can see the functions that did not work above as well).
selectInput("algorithmicMethod1",
label=h5("Berechnungsalgorithmus erster Wahl"),
c("RoT","Pickands"),
selected="RoT"),
conditionalPanel(condition="input.algorithmicMethod1 =='RoT'",
selectInput("algorithmicMethod2",
label=h5("Berechnungsalgorithmus zweiter Wahl"),
"Pickands",
selected="Pickands")),
conditionalPanel(condition="input.algorithmicMethod1 =='Pickands'",
selectInput("algorithmicMethod2",
label=h5("Berechnungsalgorithmus zweiter Wahl"),
"RoT",
selected="RoT"))
So, is there any other way to disable the select/selectize-Inputs?
Thanks again.:)
Share Improve this question edited Oct 2, 2014 at 7:59 Richard asked Oct 1, 2014 at 13:26 RichardRichard 1894 silver badges11 bronze badges 2- I don't know why this question was downvoted, but perhaps you can make it clearer by attaching a few screenshots of the workflow of your shiny app. – Alex Commented Oct 2, 2014 at 1:39
- Hey, Is nobody out there who could help? Thanks:) – Richard Commented Oct 7, 2014 at 14:09
1 Answer
Reset to default 6Solution: you can use my package shinyjs for that - you just call shinyjs::disable(id)
and it will work.
Explanation why it's not super simple: the problem is that when you use selectize, it creates another select box that is just pretty HTML but it's not a real HTML input element, so it doesn't respond to the disabled
property like real HTML tags do. Disabling a selectize can be done using JS if you look at the selectize.js documentation, but it's not very convenient with shiny. :(
If you don't use selectize (selectInput(selectize = FALSE)
), disabling will work just fine.
本文标签: javascriptDisable Selectize Input ShinyStack Overflow
版权声明:本文标题:javascript - Disable Selectize Input Shiny - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745212026a2647945.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论