Collapse Shinydashboard box from server.R

541 views
Skip to first unread message

Kevin van Blommestein

unread,
Feb 21, 2015, 10:34:15 PM2/21/15
to shiny-...@googlegroups.com

First off, thank you for Shinydashboard, it has really made things easier.

I would like to start my Shiny app with a box collapsed and when the user uploads a file, the box uncollapses. I tried to use Javascript to click the collapse button, but there is no id for the button. Is there an easy way to achieve this or should I just stick to jumping between multiple tabs using updateTabsetPanel?

Winston Chang

unread,
Feb 23, 2015, 3:07:21 PM2/23/15
to Kevin van Blommestein, shiny-discuss
Sorry, there isn't a simple way to do this right now. You could still use Javascript to trigger a click event -- you just need to use the right selector.

This will find the first box with a collapse button and trigger it.
  $('.box').find('[data-widget="collapse"]').click()

This still isn't ideal, because the box itself doesn't have an ID, so if you have multiple boxes with collapse buttons, you'll have to do a little more work to pick out the right one, by numeric position, or perhaps by finding one with a particular title associated with it. This is still all doable with jQuery, but will require a little more work.

-Winston
 

On Sat, Feb 21, 2015 at 7:34 PM, Kevin van Blommestein <kvanblo...@gmail.com> wrote:

First off, thank you for Shinydashboard, it has really made things easier.

I would like to start my Shiny app with a box collapsed and when the user uploads a file, the box uncollapses. I tried to use Javascript to click the collapse button, but there is no id for the button. Is there an easy way to achieve this or should I just stick to jumping between multiple tabs using updateTabsetPanel?

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/51b539c6-ce0f-44be-a5a2-d130097f585a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages