Created
September 28, 2016 02:08
-
-
Save happyshows/85bfa045c432c877b427e5a060b74beb to your computer and use it in GitHub Desktop.
Help needed on the following example, a couple issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(purrr) | |
library(shinyBS) | |
Module.initUI2 <- function(input,output,session) { | |
ns <- session$ns | |
output$ui_test <- renderUI({ | |
isolate({ | |
#Second time this was not triggered | |
h4('Test Success') | |
}) | |
}) | |
output$ui_statusBar <- renderUI({ | |
ui <- tagList( | |
br(),br(), | |
tags$button(id = ns('mb_inputs'),'placeholder') | |
) | |
return(ui) | |
}) | |
react_inputModal <- reactive({ | |
isolate({ | |
modal <- modalDialog(title = 'Test', easyClose = T, | |
'Removed', | |
footer = tagList( | |
bsButton(ns('bb_query'),'Load Data') | |
) | |
) | |
}) | |
}) | |
#print placeholder btn count, not working | |
observe({ | |
req(input$mb_inputs) | |
isolate({ | |
print(input$mb_inputs) | |
}) | |
}) | |
#Show Modal, not working | |
observe({ | |
input$mb_inputs | |
isolate({ | |
showModal(react_inputModal()) | |
}) | |
}) | |
react_src <- reactive({ | |
req(input$bb_query > 0) | |
isolate({ | |
removeModal() | |
dat <- data.frame() | |
}) | |
}) | |
return(react_src) | |
} | |
testUI <- function(id,title = NULL){ | |
ns <- NS(id) | |
content <- tags$div(id = id, | |
div( | |
class = "box-body", | |
uiOutput(ns('ui_statusBar')), | |
h2(title), | |
uiOutput(ns('ui_main')) | |
) | |
) | |
} | |
test <- function(input, output, session,id) { | |
ns <- NS(id) | |
react_src <- Module.initUI2(input,output,session) | |
output$ui_main <- renderUI({ | |
req(src <- react_src()) | |
isolate({ | |
uiOutput(ns('ui_test')) | |
}) | |
}) | |
} | |
shinyServer(function(input, output) { | |
output$ui_launchpad <- renderUI({ | |
isolate({ | |
tagList( | |
uiOutput('ui_call'), | |
tags$div(id='placeholder') | |
) | |
}) | |
}) | |
output$ui_call <- renderUI({ | |
isolate({ | |
tagList( | |
bsButton('cmb_modules','Call') | |
) | |
}) | |
}) | |
observe({ | |
req((val <- input$cmb_modules) > 0) | |
isolate({ | |
uid <- paste0('test',val) | |
callModule(test, uid,id = uid) | |
ins <- testUI(uid,title = uid) | |
ui <- insertUI( | |
selector = paste0('#placeholder'), | |
where = 'beforeEnd', | |
ui = ins | |
) | |
}) | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
shinyUI(fluidPage( | |
uiOutput('ui_launchpad') | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment