У меня есть actionButton с именем addbtn. Когда вы нажмете эту кнопку, она возьмет входные данные из поля textInput и создаст дополнительный текст.как вы очищаете значение в текстовом поле ввода в блестящем
Когда я нажимаю addbtn и создают поля textInput, значения в поле txtInput должны очищаться, поэтому я могу добавить больше полей ввода текста.
Это код:
УИ:
ibrary(shiny)
shinyUI(
# Use a fluid Bootstrap layout
fluidPage(
# Generate a row with a sidebar
sidebarLayout(
# Define the sidebar with one input
sidebarPanel(
sliderInput("capacity", "Current Capacity:",
min=0, max=100, value=10),
c(list(
textInput("service", "Application Component Name", ""),
actionButton("addbtn", "Add Component"))),
#lapply(seq(10), function(i) uiOutput(paste0("ui", i)))
br(),
br(),
br(),
br(),
br(),
actionButton("calcbtn", "Calculate Projection")
),
# Create a spot for the barplot
mainPanel(
textInput("inputWork","Volume", width="200px"),
textInput("inputGrowth","Growth Rate", width="100px"),
lapply(seq(10), function(i) uiOutput(paste0("ui", i)))
#tags$p("Web"),
#verbatimTextOutput("input_type_text")
)
)
)
)
server <- function(input, output)
{
observeEvent(input$addbtn, {
n <- isolate(input$addbtn)
if (n == 0) return()
# create n-th pair of text input and output
output[[paste0("ui", n)]] <- renderUI(
list(textInput(paste0("textin", n), isolate(input$service)),
textOutput(paste0("textout", n))))
updateTextInput(input$service, "Application Component Name", value="")
})
}
с этим кодом, я получаю эти ошибки:
Warning: Error in $: $ operator is invalid for atomic vectors
Stack trace (innermost first):
64: updateTextInput
63: observeEventHandler [C:\shiny\bcl/server.R#11]
1: shiny::runApp
ERROR: [on_request_read] connection reset by peer
@Batanichek, Я обновить исходное сообщение с кодом ui. Любые идеи, что мне не хватает? – user1471980