Brilliant: adding addPopover to actionLink

I want to include a small help link "Help" (next to the "ActionManager" Render), which acts like a popover (see here ). Here is my code:

server.R:

shinyUI(pageWithSidebar( sidebarPanel( actionButton("renderButton", "Render"), actionLink("link", "Help") ), mainPanel() )) 

ui.R:

 shinyServer(function(input, output, session) { # ... dealing with renderButton ... output$link <- renderUI({ addPopover(session=session, id=output$link, title="", content="Testing.", placement = "bottom", trigger = "click", options = NULL) }) }) 

Right now, actionLink appears in the sidebar, but clicking on it has no effect. Any tips? I think this may be related to id in addPopover, but I have not found many examples for creating a framework. I found this one , but I want to deal with popover on the .R server, not ui.R. Is it possible to do so, or should I just make a popover in ui.R?

+1
source share
1 answer

From ?Tooltips_and_Popovers :

The user interface of your application must have at least one shinyBS component loading order for the necessary dependencies. Because of this, addTooltip and addPopover will not work if they are the only shinyBS components in your application.

To make pop work, you can change actionButton to bsButton and change server.R to contain only addPopover call. The id argument for addPopover also needs to be changed to refer to the identifier of the ui object in which you want to include pop, in your case "link" , the actionLink identifier.

Here's the code for the modified example in a self-contained code snippet:

 library(shiny) library(shinyBS) runApp( # Ui list(ui = pageWithSidebar( headerPanel("Test App"), sidebarPanel( bsButton("renderButton", "Render"), actionLink("link", "Help") ), mainPanel("Hello World!") ), # Server server = function(input, output, session) { # ... dealing with renderButton ... addPopover(session=session, id="link", title="", content="Testing.", placement = "bottom", trigger = "click", options = NULL) }) ) 
+2
source

Source: https://habr.com/ru/post/1238935/


All Articles