简体   繁体   中英

shinyjs won't hide button created with renderUI

I have a shiny app in production with shinyproxy. On server.R i create some UI element using renderUI as below:

  output$guess <- renderUI({

    url <- a("Vai al sito", href = text_info()$url,target="_blank")

    tagList(
      div(h4("Osservazioni ancora da classificare:", count_obs()), style = "margin-left: 68%; color: #ff944d;"),
      div(h1("Descrizione Business:"), tags$i(h2(paste(text_info()$info))),
                                     tags$br(),
                                     "Website:", url,
                                     style = "margin-right: 5%;", class = "ui raised segment"),
      tags$br(),
      div(h3(paste("Proposta algoritmo:", text_info()$entity_class_name), style = "margin-right: 0%; color:orange")),
      tags$br(),
      h3(HTML("testo testo")),
      div(selectInput("yncheck", "", choices = c("",data_lookup$entity_class_name)), style = "margin-left: 33%;"),
      tags$br(),
      div( style = "margin-left: 2%",
      tags$button(
        id = "ynapproved", style = "margin-right: 5%; color:green;",
        class = "ui button check-button", "Approva", tags$i(class = "check icon")
      ),
      tags$button(
        id = "yndiscarded", style = "margin-right: 5%; color:red;",
        class = "ui button check-button", "Scarta", tags$i(class = "times icon")
      ),
      tags$button(
        id = "ynsuspend", style = "margin-right: 5%; color:SlateBlue;",
        class = "ui button check-button", "Sospendi", tags$i(class = "hand paper outline icon")
      ),
      tags$br(),
      tags$button(
        id = "submit",style = "margin-top: 5%; margin-right: 3%",
        class = "ui button submit-button", "Salva modifiche", tags$i(class = "save icon"))
      )
    )
  })

And

ui.R




 library(shiny)
    library(shiny.semantic)
    library(shinyalert)
    library(shinyjs)
    
    semanticPage(
      title = "mYapp",
      includeCSS("www/styles.css"),
      suppressDependencies("bootstrap"),
      useShinyalert(),
      useShinyjs(),
      div(
        class = "ui center aligned grid",
        div(
          class = "ten wide column", align = "center",
          div(
            class = "ui clearing segment",
            div(radioButtons(inputId = "ynswitch", label = "Scegli dataset",
                             choices = c("Dati1",
                                         "Dati2",
                                         "Dati3"),
                             selected='Dati1',
                             inline=TRUE),
                style = "font-size: 13px; font-weight: bold; text-align:left;" ),
            uiOutput("guess")
          )
        )
      )

I'd like to hide the ynsuspended button when user click a particular value of a radioButtons named ynswitch .

So i tried to use shinyjs inside server.R

  observeEvent(input$ynswitch, {

    if(input$ynswitch=='Dati2')
      {shinyjs::hide("ynsuspend")}
  })

But it doesn't work. Element isn't hidden.

Thanks

thanks for the answer. I solved using delay for shinyjs:

https://github.com/daattali/shinyjs/issues/166

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM