fabricerin icon indicating copy to clipboard operation
fabricerin copied to clipboard

Render image inside dynamically created UI?

Open dcaud opened this issue 5 years ago • 3 comments

Would it be be possible to render image inside a UI element that is dynamically created?

Seems like a little javascript would need to be changed.

I'm looking for something like this:

library(fabricerin)

ui <- fluidPage(
  actionButton("render", "Put image on Canvas!"),
  uiOutput("gen.in.server")
  
)

server <- function(input, output) {
  
  observeEvent(input$render,{

    output$gen.in.server <- 
      renderUI({
        
        fabric_image(cid = "cimage",
                     cfill = "lightblue",
                     imgId = "Rimg",
                     imgsrc = "https://upload.wikimedia.org/wikipedia/commons/thumb/1/1b/R_logo.svg/724px-R_logo.svg.png")
      })
  })
  
}


shinyApp(ui = ui, server = server)

dcaud avatar Oct 11 '20 22:10 dcaud

hi @dcaud ,

I've tried the code that you've provided and it worked. Try to click twice on the action button and tell me please if it worked.

Best.

feddelegrand7 avatar Oct 14 '20 09:10 feddelegrand7

Nice find! Interesting that clicking twice works. It seems like a bug somewhere and I'm not sure how to fix it.

dcaud avatar Oct 14 '20 14:10 dcaud

Indeed, there is a problem somewhere but can't find it. I won't clause this issue in case someone can fix it.

feddelegrand7 avatar Oct 14 '20 14:10 feddelegrand7