发布
社区首页 >问答首页 >R:如何根据另一个主actionButtons按顺序生成actionButton

R:如何根据另一个主actionButtons按顺序生成actionButton
EN

Stack Overflow用户
提问于 2014-03-04 12:13:19
回答 1查看 284关注 0票数 1

我试图根据actionButton的值为UI生成一些输入。生成textInputs很好(请参阅下面的可重复代码),但是生成actionButtons似乎很棘手。

以下是代码:

代码语言:javascript
代码运行次数:0
复制
shiny::runApp(
list(
ui = pageWithSidebar(
headerPanel("test"),
sidebarPanel(
actionButton("create","create")
),    
mainPanel(  
uiOutput('the_textInputs'),
uiOutput('the_buttons')
))
, 
server = function(input,output){
observe({
if (input$create == 0) 
return()
isolate({  

output$the_textInputs <- renderText({ #this works nicely
A <- paste0("<input id='A", 1:input$create, "' class='shiny-bound-input' type='text' value=''>")
})

output$the_buttons <- renderUI({ # this does not work properly, probably due to the html commands here below not well specified
B <- paste0("<input id='B", 1:input$create, "' class='btn action-button' type='button' >")
})

})
})

}
))

如有任何建议或建议,将不胜感激!

干杯

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-04 12:25:49

renderUI中,您只能使用“返回闪亮的标记对象、HTML或此类对象列表的表达式”。

必须更改output$the_buttons <- renderTextrenderUI函数,将字符串转换为HTML:B <- HTML(paste0("<input id='B", 1:input$create, "' class='btn action-button' type='button' >"))

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22171664

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档