2017-04-19 27 views
0

これはthisの質問に続きます。前の質問では、selectInputの境界が、次の引数tags$head(tags$style(HTML("#Select1 ~ .selectize-control.single .selectize-input {border: 1px solid #dd4b39;}")))を使用してui側から変更されました。今私は特定の選択された出力の境界線の色をサーバー側から変更したいと思います。私の主な目的は、実際には異なる条件に基づいて色を変更することです。サーバー側から色を変更するには、次のコードを試しましたが、動作しないようです。これを達成する方法はありますか?ここでselectinputの境界線の色をサーバー側から変更してください。

は、私が試したコードです:

library(shiny) 

    ui <- fluidPage(

    tags$head(tags$style(htmlOutput("Border_Arg"))), 

    selectInput("Select1", "Option1", choices = NULL), 

    selectInput("Select2", "Option2", choices = NULL) 
) 


    server <- function(input, output){ 
    output$Border_Arg <- renderUI({"#Select1 ~ .selectize-control.single .selectize-input {border: 1px solid #dd4b39;}"}) 
    } 

    shinyApp(ui = ui, server = server) 

答えて

1

あなたが接近していました。

は、以下の実行している例を探す:

library(shiny) 
ui <- fluidPage(
    selectInput("Select1", "Option1", choices = NULL), 
    selectInput("Select2", "Option2", choices = NULL), 
    uiOutput("Border_Arg") 
) 


server <- function(input, output){ 
    output$Border_Arg <- renderUI({ 
    tags$head(tags$style(HTML("#Select1 ~ .selectize-control.single .selectize-input {border: 1px solid #dd4b39;}"))) 
    }) 
} 

shinyApp(ui = ui, server = server) 
+0

ありがとうございました。これはまさに私が望んでいたものです。 – SBista

関連する問題