Reputation: 284
Can anyone tell me how to use this onclick function in server its working on ui but i need to use this on server or is it possible to observe the url so that i can use the url once the button is clicked
Thanks in Advance
u_id<-"123"
inv_id <-222
url <- paste0("https://www.google.com/","?id=",u_id, "&inv_id=", inv_id)
ui <- fluidPage(
titlePanel("open url"),
sidebarLayout(
sidebarPanel(
actionButton("id",
label = "ADD COMMENT",
icon = icon("Click"))
),
mainPanel(
)
))
server <- function(input, output, session) {
onclick("id",sprintf("window.open('%s','win','resizable,height=400,width=400')",url))
}
shinyApp(ui, server)
Upvotes: 1
Views: 595
Reputation: 7350
onClick
from server.runjs
to run js from server.u_id<-"123"
inv_id <-222
url <- paste0("https://www.google.com/","?id=",u_id, "&inv_id=", inv_id)
library(shiny)
library(shinyjs)
ui <- fluidPage(
useShinyjs(),
titlePanel("open url"),
sidebarLayout(
sidebarPanel(
actionButton("id",
label = "ADD COMMENT",
icon = icon("Click"))
),
mainPanel(
)
))
server <- function(input, output, session) {
onclick(id = "id", runjs(sprintf("window.open('%s','win','resizable,height=400,width=400')",url)))
}
shinyApp(ui, server)
Upvotes: 1