Ram*_*ath 14
这是一种方法.关键是dblclick在客户端检测事件(即ui),然后调用Shiny.onInputChange以更新R变量的值,然后服务器可以获取该变量的值.
这是双击按钮时发生的情况.
x.xtextOutput.Run Code Online (Sandbox Code Playgroud)library(shiny) ui = bootstrapPage( tags$button(id = 'mybutton', 'button', class='btn btn-primary', value = 0), textOutput('x'), # when button is double clicked increase the value by one # and update the input variable x tags$script(" $('#mybutton').on('dblclick', function(){ var val = +this.value this.value = val + 1 Shiny.onInputChange('x', this.value) console.log(this.value) }) ") ) server = function(input, output, session){ output$x <- renderText({ input$x }) } runApp(list(ui = ui, server = server))
| 归档时间: |
|
| 查看次数: |
1871 次 |
| 最近记录: |