簡體   English   中英

閃亮:將addPopover添加到actionLink

[英]Shiny: adding addPopover to actionLink

我想包含一個小的“幫助” actionLink(“渲染” actionButton的旁邊),它充當彈出窗口(請參見此處 )。 這是我的代碼:

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)
   })
})

現在,actionLink出現在側欄上,但是單擊它沒有任何作用。 有小費嗎? 我認為這可能與addPopover中的id有關,但是我沒有發現很多提供框架的示例。 我找到 ,但是我想處理server.R中的彈出窗口,而不是ui.R。 可以通過這種方式完成,還是應該在ui.R中創建彈出窗口?

?Tooltips_and_Popovers

應用的用戶界面中必須至少有一個ShinyBS組件,以便加載必需的依賴項。 因此,如果addTooltip和addPopover是應用程序中唯一的ShinyBS組件,它們將無法工作。

要使彈出窗口起作用,您可以將actionButton更改為bsButton ,然后將server.R修改為僅包含對addPopover的調用。 還需要更改addPopoverid參數,以引用要在其上顯示彈出窗口的ui對象的ID,在您的情況下為"link" ,即actionLink的ID。

這是自包含代碼塊中的修改后的示例代碼:

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)

  })
)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM