Background
I want to change some elements of a shinydashboard::box
. Say, I want to change the icon used for collapsing a box(collapsible = TRUE)
. Looking at the output, all I need to do is to change the <i>
tag accordingly:
(b <- box(collapsible = T))
# <div class="col-sm-6">
# <div class="box">
# <div class="box-header">
# <div class="box-tools pull-right">
# <button class="btn btn-box-tool" data-widget="collapse">
# <i class="fa fa-minus"></i> ## change to <i class="fa fa-times">
# </button>
# </div>
# </div>
# <div class="box-body"></div>
# </div>
# </div>
Challenge
While I could do some recursive looping through b$children
to find the right children element like in
b$children[[1]]$children[[1]]$children[[2]]$children[[1]]$children[[1]]$attribs$class <- "fa fa-times"
I was wondering, whether there is not an easier way? Ideally something resembling jQuery
syntax?
Another option would be to write my own box
function, but I want to avoid that code duplication.