r - 在 R Shiny 中通过 bsbutton 插入 UI。单击按钮时,UI 不会插入。请问有什么帮助吗?
问题描述
我正在尝试创建一个交互式 UI,它在用户与其交互时要求提供更多详细信息。我添加了一个 bsButton,它应该插入更多输入选项以收集更多详细信息,但是单击该按钮时不会插入 UI。对代码有任何帮助或建议吗?提前致谢。
ui <- shinyUI( #UI
dashboardPage(
fluidPage(
fluidRow(
introBox(
bsButton("pricing_request", #button to insert UI to collect more details
label = "Pricing Request",
icon = icon("car-battery"),
style = "success")
)))))
#serverpart
server <- function(input, output, session) {
observeEvent(input$pricing_request,{
insertUI(
selector = "#add",
where = "afterEnd",
ui = box( #UI to be inserted
bootstrapPage(
div(style="float:right", actionButton("add_request",
label = "add option",
icon = icon("plus"),
style = "arial")),
div(style="display:inline-block",
textInput(
inputId = "option_1",
label = "Option",
width = '350px',
value = "insert option"))))
)})}
解决方案
通过写作
insertUI(
selector = "#add",
where = "afterEnd",
......
您请求在 id 为 .html 的 HTML 元素之后添加一个 UI add
。但是您的应用程序中没有这样的元素。如果您div(id = "add")
在应用程序中添加某个位置,那应该可以。
推荐阅读
- r - omega 函数(Psych 包 R)不适用于 plot=TRUE
- javascript - 将 fetch 与 Passport 一起使用会得到“请求的资源上不存在 'Access-Control-Allow-Origin' 标头。”
- javascript - Next.JS 和 Nodemailer,从联系表单发送电子邮件
- reactjs - 故事书投掷错误
- ios - 重复的符号
- reactjs - 在包中使用 Material UI 时,只能在函数组件的主体内部调用 Hooks
- c++ - 是否在没有对象未定义行为的情况下访问静态 struct::var?
- java - Java中“if”和“if else”的不同表现
- python - 使用带有 PyQt5 和 OpenGL 的 VBO 绘制多个对象?
- sql - 获取每个组的前 5 条记录并将它们连接到每组的一行中