Disable Elements When Shiny Is Busy
I'm using a piece of javascript from this question: SO It works for buttons, but I would also like to disable things like sliderInput, selectInput and textInput as well. I tried t
Solution 1:
I cannot help you with the close button, though I found out that as soon as you set your shiny:idle
handle, any call to JavaScript will fire shiny:idle
and hence runs the handler instead of the JavaScript code behind toggleDropdownButton
.
However, the first question of how to select more than one element in your JavaScript can be solved with a bit of jQuery
. Change your code to
$(document).on('shiny:busy', function() {
var $inputs = $('button,input');
console.log($inputs);
$inputs.prop('disabled', true);
});
$(document).on('shiny:idle', function() {
var $inputs = $('button,input');
console.log($inputs);
$inputs.prop('disabled', false);
})
With that you can select buttons and the text input. Now you can find out yourself which code to use to also disable the dropdown.
BTW: maybe you want to look at shinyjs::disable
. With this function you can disable your controls from the R
side. You would put that in the beginning of your long calculation and use shinyjs::enable
at the end.
Post a Comment for "Disable Elements When Shiny Is Busy"