R Shiny: Reactive Value in Modal not working2019 Community Moderator ElectionBind a function to Twitter Bootstrap Modal CloseDisallow Twitter Bootstrap modal window from closingBootstrap modal appearing under backgroundPrevent Bootstrap Modal from disappearing when clicking outside or pressing escape?Close Bootstrap ModalDisable click outside of bootstrap modal area to close modalAdd values to a reactive table in shinyR Shiny: reactiveValues vs reactiveShiny: dynamic dataframe construction; renderUI, observe, reactiveValuesR Shiny - Editing a data table inside a dynamically created bsModal

Light propagating through a sound wave

Violin - Can double stops be played when the strings are not next to each other?

Can other pieces capture a threatening piece and prevent a checkmate?

Knife as defense against stray dogs

Fewest number of steps to reach 200 using special calculator

Hausdorff dimension of the boundary of fibres of Lipschitz maps

Why is there so much iron?

Generic TVP tradeoffs?

What does "mu" mean as an interjection?

Can a wizard cast a spell during their first turn of combat if they initiated combat by releasing a readied spell?

Is there a term for accumulated dirt on the outside of your hands and feet?

Can you move over difficult terrain with only 5 feet of movement?

Does the attack bonus from a Masterwork weapon stack with the attack bonus from Masterwork ammunition?

How to generate binary array whose elements with values 1 are randomly drawn

Do native speakers use "ultima" and "proxima" frequently in spoken English?

Do I need to consider instance restrictions when showing a language is in P?

Do US professors/group leaders only get a salary, but no group budget?

Would it be believable to defy demographics in a story?

Existence of a celestial body big enough for early civilization to be thought of as a second moon

What exactly term 'companion plants' means?

Maths symbols and unicode-math input inside siunitx commands

Recruiter wants very extensive technical details about all of my previous work

Optimising a list searching algorithm

In what cases must I use 了 and in what cases not?



R Shiny: Reactive Value in Modal not working



2019 Community Moderator ElectionBind a function to Twitter Bootstrap Modal CloseDisallow Twitter Bootstrap modal window from closingBootstrap modal appearing under backgroundPrevent Bootstrap Modal from disappearing when clicking outside or pressing escape?Close Bootstrap ModalDisable click outside of bootstrap modal area to close modalAdd values to a reactive table in shinyR Shiny: reactiveValues vs reactiveShiny: dynamic dataframe construction; renderUI, observe, reactiveValuesR Shiny - Editing a data table inside a dynamically created bsModal










0















The header of my modalDialog is a reactiveValue. Once a certain input is changed within the modal, I would like the header to change. I have tried a few different ways and haven't been able to get it working seamlessly. The header either doesn't update, only updates if I close/reopen the modal, or causes the modal to re-render completely when the header is updated immediately.



Currently, I'm stuck on the last one (modal re-rendering completely). However, when I created the minimal, reproducible example (below), the header only updates if I close & reopen the modal.



ui<-fluidPage(
actionButton(inputId="model", label="Edit Model")
)

server<-function(input, output, session)
rv<-reactiveValues(header="Standard Model")

observeEvent(input$model,
showModal(
modalDialog(
fluidPage(
fluidRow(h3(rv$header)),
sliderInput(inputId="factor_1", "Factor #1", value=70, min=0, max=100),
sliderInput(inputId="factor_2", "Factor #2", value=30, min=0, max=100)
),
footer=modalButton("Save Weights"), size="s", easyClose=TRUE
)
)
)

observe(if (!is.null(input$factor_1))
if (input$factor_1!=70)
rv$header<-"Custom Model"


)


shinyApp(ui=ui, server=server)


Essentially, I want the title to change from 'Standard Model' to 'Custom Model' (without closing/reopening or re-rendering the modal) once the input for Factor #1 is changed for the first time.










share|improve this question


























    0















    The header of my modalDialog is a reactiveValue. Once a certain input is changed within the modal, I would like the header to change. I have tried a few different ways and haven't been able to get it working seamlessly. The header either doesn't update, only updates if I close/reopen the modal, or causes the modal to re-render completely when the header is updated immediately.



    Currently, I'm stuck on the last one (modal re-rendering completely). However, when I created the minimal, reproducible example (below), the header only updates if I close & reopen the modal.



    ui<-fluidPage(
    actionButton(inputId="model", label="Edit Model")
    )

    server<-function(input, output, session)
    rv<-reactiveValues(header="Standard Model")

    observeEvent(input$model,
    showModal(
    modalDialog(
    fluidPage(
    fluidRow(h3(rv$header)),
    sliderInput(inputId="factor_1", "Factor #1", value=70, min=0, max=100),
    sliderInput(inputId="factor_2", "Factor #2", value=30, min=0, max=100)
    ),
    footer=modalButton("Save Weights"), size="s", easyClose=TRUE
    )
    )
    )

    observe(if (!is.null(input$factor_1))
    if (input$factor_1!=70)
    rv$header<-"Custom Model"


    )


    shinyApp(ui=ui, server=server)


    Essentially, I want the title to change from 'Standard Model' to 'Custom Model' (without closing/reopening or re-rendering the modal) once the input for Factor #1 is changed for the first time.










    share|improve this question
























      0












      0








      0








      The header of my modalDialog is a reactiveValue. Once a certain input is changed within the modal, I would like the header to change. I have tried a few different ways and haven't been able to get it working seamlessly. The header either doesn't update, only updates if I close/reopen the modal, or causes the modal to re-render completely when the header is updated immediately.



      Currently, I'm stuck on the last one (modal re-rendering completely). However, when I created the minimal, reproducible example (below), the header only updates if I close & reopen the modal.



      ui<-fluidPage(
      actionButton(inputId="model", label="Edit Model")
      )

      server<-function(input, output, session)
      rv<-reactiveValues(header="Standard Model")

      observeEvent(input$model,
      showModal(
      modalDialog(
      fluidPage(
      fluidRow(h3(rv$header)),
      sliderInput(inputId="factor_1", "Factor #1", value=70, min=0, max=100),
      sliderInput(inputId="factor_2", "Factor #2", value=30, min=0, max=100)
      ),
      footer=modalButton("Save Weights"), size="s", easyClose=TRUE
      )
      )
      )

      observe(if (!is.null(input$factor_1))
      if (input$factor_1!=70)
      rv$header<-"Custom Model"


      )


      shinyApp(ui=ui, server=server)


      Essentially, I want the title to change from 'Standard Model' to 'Custom Model' (without closing/reopening or re-rendering the modal) once the input for Factor #1 is changed for the first time.










      share|improve this question














      The header of my modalDialog is a reactiveValue. Once a certain input is changed within the modal, I would like the header to change. I have tried a few different ways and haven't been able to get it working seamlessly. The header either doesn't update, only updates if I close/reopen the modal, or causes the modal to re-render completely when the header is updated immediately.



      Currently, I'm stuck on the last one (modal re-rendering completely). However, when I created the minimal, reproducible example (below), the header only updates if I close & reopen the modal.



      ui<-fluidPage(
      actionButton(inputId="model", label="Edit Model")
      )

      server<-function(input, output, session)
      rv<-reactiveValues(header="Standard Model")

      observeEvent(input$model,
      showModal(
      modalDialog(
      fluidPage(
      fluidRow(h3(rv$header)),
      sliderInput(inputId="factor_1", "Factor #1", value=70, min=0, max=100),
      sliderInput(inputId="factor_2", "Factor #2", value=30, min=0, max=100)
      ),
      footer=modalButton("Save Weights"), size="s", easyClose=TRUE
      )
      )
      )

      observe(if (!is.null(input$factor_1))
      if (input$factor_1!=70)
      rv$header<-"Custom Model"


      )


      shinyApp(ui=ui, server=server)


      Essentially, I want the title to change from 'Standard Model' to 'Custom Model' (without closing/reopening or re-rendering the modal) once the input for Factor #1 is changed for the first time.







      r shiny modal-dialog






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 6 at 22:04









      Sean SlavinSean Slavin

      278




      278






















          1 Answer
          1






          active

          oldest

          votes


















          1














          Using renderUI/uiOutput:



          library(shiny)

          ui <- fluidPage(
          actionButton("model", label = "Edit Model")
          )

          server <- function(input, output, session)

          rv <- reactiveValues(header = "Standard Model")

          observeEvent(input[["model"]],
          showModal(
          modalDialog(
          fluidPage(
          uiOutput("modalTitle"),
          sliderInput("factor_1", "Factor #1", value=70, min=0, max=100),
          sliderInput("factor_2", "Factor #2", value=30, min=0, max=100)
          ),
          footer = modalButton("Save Weights"),
          size="s", easyClose=TRUE
          )
          )
          )

          output[["modalTitle"]] <- renderUI(
          fluidRow(h3(rv$header))
          )

          observe(
          if (!is.null(input$factor_1))
          if (input$factor_1 != 70)
          rv$header <- "Custom Model"


          )



          shinyApp(ui=ui, server=server)


          enter image description here






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55032897%2fr-shiny-reactive-value-in-modal-not-working%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Using renderUI/uiOutput:



            library(shiny)

            ui <- fluidPage(
            actionButton("model", label = "Edit Model")
            )

            server <- function(input, output, session)

            rv <- reactiveValues(header = "Standard Model")

            observeEvent(input[["model"]],
            showModal(
            modalDialog(
            fluidPage(
            uiOutput("modalTitle"),
            sliderInput("factor_1", "Factor #1", value=70, min=0, max=100),
            sliderInput("factor_2", "Factor #2", value=30, min=0, max=100)
            ),
            footer = modalButton("Save Weights"),
            size="s", easyClose=TRUE
            )
            )
            )

            output[["modalTitle"]] <- renderUI(
            fluidRow(h3(rv$header))
            )

            observe(
            if (!is.null(input$factor_1))
            if (input$factor_1 != 70)
            rv$header <- "Custom Model"


            )



            shinyApp(ui=ui, server=server)


            enter image description here






            share|improve this answer



























              1














              Using renderUI/uiOutput:



              library(shiny)

              ui <- fluidPage(
              actionButton("model", label = "Edit Model")
              )

              server <- function(input, output, session)

              rv <- reactiveValues(header = "Standard Model")

              observeEvent(input[["model"]],
              showModal(
              modalDialog(
              fluidPage(
              uiOutput("modalTitle"),
              sliderInput("factor_1", "Factor #1", value=70, min=0, max=100),
              sliderInput("factor_2", "Factor #2", value=30, min=0, max=100)
              ),
              footer = modalButton("Save Weights"),
              size="s", easyClose=TRUE
              )
              )
              )

              output[["modalTitle"]] <- renderUI(
              fluidRow(h3(rv$header))
              )

              observe(
              if (!is.null(input$factor_1))
              if (input$factor_1 != 70)
              rv$header <- "Custom Model"


              )



              shinyApp(ui=ui, server=server)


              enter image description here






              share|improve this answer

























                1












                1








                1







                Using renderUI/uiOutput:



                library(shiny)

                ui <- fluidPage(
                actionButton("model", label = "Edit Model")
                )

                server <- function(input, output, session)

                rv <- reactiveValues(header = "Standard Model")

                observeEvent(input[["model"]],
                showModal(
                modalDialog(
                fluidPage(
                uiOutput("modalTitle"),
                sliderInput("factor_1", "Factor #1", value=70, min=0, max=100),
                sliderInput("factor_2", "Factor #2", value=30, min=0, max=100)
                ),
                footer = modalButton("Save Weights"),
                size="s", easyClose=TRUE
                )
                )
                )

                output[["modalTitle"]] <- renderUI(
                fluidRow(h3(rv$header))
                )

                observe(
                if (!is.null(input$factor_1))
                if (input$factor_1 != 70)
                rv$header <- "Custom Model"


                )



                shinyApp(ui=ui, server=server)


                enter image description here






                share|improve this answer













                Using renderUI/uiOutput:



                library(shiny)

                ui <- fluidPage(
                actionButton("model", label = "Edit Model")
                )

                server <- function(input, output, session)

                rv <- reactiveValues(header = "Standard Model")

                observeEvent(input[["model"]],
                showModal(
                modalDialog(
                fluidPage(
                uiOutput("modalTitle"),
                sliderInput("factor_1", "Factor #1", value=70, min=0, max=100),
                sliderInput("factor_2", "Factor #2", value=30, min=0, max=100)
                ),
                footer = modalButton("Save Weights"),
                size="s", easyClose=TRUE
                )
                )
                )

                output[["modalTitle"]] <- renderUI(
                fluidRow(h3(rv$header))
                )

                observe(
                if (!is.null(input$factor_1))
                if (input$factor_1 != 70)
                rv$header <- "Custom Model"


                )



                shinyApp(ui=ui, server=server)


                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 7 at 8:57









                Stéphane LaurentStéphane Laurent

                15.5k75696




                15.5k75696





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55032897%2fr-shiny-reactive-value-in-modal-not-working%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                    Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                    Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved