R Shiny:在页面访问时显示一个ShinyBS Modal弹出窗口(无用户操作) [英] R Shiny: Present a ShinyBS Modal Popup on page visit (no user action)

查看:160
本文介绍了R Shiny:在页面访问时显示一个ShinyBS Modal弹出窗口(无用户操作)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前在代码中成功使用了bsModal.但是,默认情况下,我似乎无法弹出模态弹出窗口来仅显示用户何时访问应用程序的首页.我以为这样的事情会奏效,但行不通.知道如何触发页面访问中的bsModal吗?

I used bsModal successfully in my code before. However, I can't seem to get a modal pop up to show just when the user visits an app's first page by default. I thought something like this would work, but not. Any idea how I can trigger a bsModal on page visit?

library(shiny)
library(shinyBS)

ui <- fluidPage(
  mainPanel(
    bsModal(id = 'startupModal', title = 'Dum Dum', trigger = '',
            size = 'large', p("here is my mumbo jumbo")),
    width = 12
  )
)

server <- function(input, output, session) {

}

shinyApp(ui = ui, server = server)

我只需要在用户访问应用程序时向其发出一条消息来提醒用户,然后允许他们关闭模式弹出窗口并自由浏览应用程序的其余部分.我正在使用Shinydashboard.因此,最终,这必须与之配合.

I simply need to alert the user with a message when they visit the app and then allow them to close the modal pop up and navigate the rest of the app freely. I am using Shinydashboard. So, eventually, this has to work with that.

推荐答案

您可以使用toggleModal手动触发服务器上的弹出窗口.

You can use toggleModal to manually trigger the popup from the server.

library(shiny)
library(shinyBS)

ui <- fluidPage(
  mainPanel(
    bsModal(id = 'startupModal', title = 'Dum Dum', trigger = '',
            size = 'large', p("here is my mumbo jumbo")),
    width = 12
  )
)

server <- function(input, output, session) {
  toggleModal(session, "startupModal", toggle = "open")
}

shinyApp(ui = ui, server = server)

这篇关于R Shiny:在页面访问时显示一个ShinyBS Modal弹出窗口(无用户操作)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆