点击动作按钮的瞬间(Moment of click on action button)

编程入门 行业动态 更新时间:2024-10-28 01:19:05
点击动作按钮的瞬间(Moment of click on action button)

我有一个关于闪亮应用程序中的actionButon()函数的问题。 在RStudio Shiny网站中,解释了actionButton包含一些将数字发送到服务器的JavaScript代码。 当Web浏览器第一次连接时,它会发送一个值0,并且每次点击时它会发送一个递增的值:1,2,3等等。 如何知道用户何时点击按钮而不使用按钮的值?

谢谢

I have a question concerning the actionButon() function in shiny application. In the RStudio Shiny Web site, it is explained that the actionButton includes some JavaScript code that sends numbers to the server. When the web browser first connects, it sends a value of 0, and on each click, it sends an incremented value: 1, 2, 3, and so on. How is possible to know when the users clicks on the button without using the value of the button?

Thanks

最满意答案

shinyjs软件包通过onclick和onevent内置的功能可以调整您的需求。 以下示例来自https://github.com/daattali/shinyjs/issues/33

if (interactive()) { library(shiny) shinyApp( ui = fluidPage( useShinyjs(), # Set up shinyjs actionButton("date", "date"), actionButton("coords", "coords"), actionButton("disappear", "disappear"), actionButton("text", "text") ), server = function(input, output) { onclick("date", alert(date())) onclick("coords", function(event) { alert(event) }) onevent("mouseenter", "disappear", hide("text")) onevent("mouseleave", "disappear", show("text")) } ) }

shinyjs package has this functionality via onclick and onevent built in so you can tailor yo your needs. Example below is taken from https://github.com/daattali/shinyjs/issues/33

if (interactive()) { library(shiny) shinyApp( ui = fluidPage( useShinyjs(), # Set up shinyjs actionButton("date", "date"), actionButton("coords", "coords"), actionButton("disappear", "disappear"), actionButton("text", "text") ), server = function(input, output) { onclick("date", alert(date())) onclick("coords", function(event) { alert(event) }) onevent("mouseenter", "disappear", hide("text")) onevent("mouseleave", "disappear", show("text")) } ) }

更多推荐

actionButon,sends,发送,value,电脑培训,计算机培训,IT培训"/> <meta name="de

本文发布于:2023-08-04 15:37:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1417608.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按钮   瞬间   动作   Moment   action

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!