Closed am2222 closed 4 years ago
Could you please include a small reproducible example so I can test
All functions should work in modules, here's an example of using additem
in a module
library(shiny)
library(timevis)
timevis_ui <- function(id) {
ns <- NS(id)
tagList(
timevisOutput(ns("timevisui")),
actionButton(ns("add"), "Add")
)
}
timevis_server <- function(input, output, session) {
output$timevisui <- renderTimevis({
timevis()
})
observeEvent(input$add, {
addItem("timevisui", list(start = Sys.Date(), content = "Today"))
})
}
ui <- fluidPage(
timevis_ui("test")
)
server <- function(input, output, session) {
callModule(timevis_server, "test")
}
shinyApp(ui, server)
I'm closing this issue for now. If you still think something isn't working, feel free to open a new issue and please include sample code
@daattali Thanks for the example,
But in your example the add button adds a line on the current date time which there is one by default in the current date and time. If I change the start to Sys.Date()-2
it does not add anything
library(shiny)
library(timevis)
timevis_ui <- function(id) {
ns <- NS(id)
tagList(
timevisOutput(ns("timevisui")),
actionButton(ns("add"), "Add")
)
}
timevis_server <- function(input, output, session) {
output$timevisui <- renderTimevis({
timevis()
})
observeEvent(input$add, {
addItem("timevisui", list(start = Sys.Date()-2, content = "Two days ago"))
})
}
ui <- fluidPage(
timevis_ui("test")
)
server <- function(input, output, session) {
callModule(timevis_server, "test")
}
shinyApp(ui, server)
Hi, In a modular shiny app we define the ids by a
ns(id)
function which gives us the id of the html element based on namespace in a format ofnamespace-id
. this causes a problem in some functions such asaddItem
which gets the id of the html object. I tried to usenamespace-id
as well but it seems it is not working, is there any workaround for it?