ShinyJS: hiding in a modal

278 views
Skip to first unread message

Vladislav Fridkin

unread,
Oct 14, 2016, 1:30:18 AM10/14/16
to Shiny - Web Framework for R
Is there a way to hide input elements in a modalDialog?

When trying to hide an input element in a modalDialog, the entire modal window gets hidden instead.
 

Dean Attali

unread,
Oct 15, 2016, 7:24:05 AM10/15/16
to Shiny - Web Framework for R
I'm the author of shinyjs - I just took a look and from what it seems it appears to be a bug in shiny. I opened an issue on github https://github.com/rstudio/shiny/issues/1427

bar...@rstudio.com

unread,
Oct 18, 2016, 4:07:34 AM10/18/16
to Shiny - Web Framework for R
As Dean said, there appears to be something wrong with Shiny if you use `el.trigger("hidden")`. I'm looking into that. However, `el.hide()` works as expected. Maybe this solves your problem..?

Vladislav Fridkin

unread,
Oct 26, 2016, 12:52:22 AM10/26/16
to Shiny - Web Framework for R
Thanks Bárbara, the shinyJS command for hiding the element that I am using is:

hide('myID')

And it hides the entire modal.  The element is introduced in a modalDialog with:

fileInput('myID', 'Input File')

I've tried

runjs("document.getElementById('myID').hide()")

and it didn't work.  How do I apply `el.hide()`?

Bárbara Borges

unread,
Oct 26, 2016, 5:54:21 AM10/26/16
to Shiny - Web Framework for R
Hi Vladislav,

Actually, I think this may be solved in Shiny's latest devel version. Try installing that and running your original code. Let me know if it doesn't work.

Also `hide()` is a JQuery method, so if you're just using vanilla JS, you can do: `document.getElementById('id').style.display = 'none';`

If you're using JQuery, then you can do: `$('#id').hide();`

Hope you get that working!
Barbara
Reply all
Reply to author
Forward
0 new messages