Yang-Tang / shinyjqui

jQuery UI Interactions and Effects for Shiny
https://yang-tang.github.io/shinyjqui/
Other
273 stars 32 forks source link

Bookmarking not working with insertUI #36

Closed JesusPF1981 closed 3 years ago

JesusPF1981 commented 5 years ago

I have created an App that generates 3 plots, when user click on Add plot (using insertUI).

If you try to Add one plot and resize it, if you want to bookmark the app, the size and position are not correctly saved.

Im using the last shinyjqui version with R 3.3 and R 3.5 also in windows and linux, but noone works

Here is my app:

library(shiny) library(shinyjqui)

ui <- function(request) { fluidPage( bookmarkButton(), sidebarLayout( actionButton("add", "Add Element"), mainPanel(id = "content") ) ) }

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

addItem <- function(id) { insertUI( selector = "#content", where = "beforeEnd", ui = tagList( jqui_resizable(plotOutput(id)) ) ) }

observeEvent(input$add, { id <- paste0("plot", input$add) addItem(id) })

output$plot1 <- renderPlot( plot(c(3,2,2)) )

onRestore(function(state) { for (i in seq_len(input$add)) { id <- paste0("plot", i) addItem(id) } }) jqui_bookmarking() }

enableBookmarking("url") shinyApp(ui, server)


Thanks Jesús

Yang-Tang commented 3 years ago

The code should work now with the bug fixing 9bbaab7ecedc9d384ff296107e78210893b21a38