RinteRface / shinyMobile

shiny API for Framework7 (IOS/android)
https://shinymobile.rinterface.com
407 stars 74 forks source link

General error on `f7Popup()` function #246

Closed SCasanova closed 1 year ago

SCasanova commented 1 year ago

Every time I try to use f7Popup() I get the following, regardless of use:

R Version: 4.2.2 shinyMobile Version: 1.0.0 shiny Version: 1.7.4

shinyMobile::f7Popup(
        id = "popup1")
#> Error in session$ns(id): attempt to apply non-function

Created on 2023-08-09 with reprex v2.0.2

DivadNojnarg commented 1 year ago

Yes that make sense because you can't run it outside the shiny app server function:

shinyMobile::f7Popup(id = "popup1")

Please look at this example from the documentation:

library(shiny)
 library(shinyMobile)
 shinyApp(
   ui = f7Page(
     title = "Popup",
     f7SingleLayout(
      navbar = f7Navbar(
        title = "f7Popup",
        hairline = FALSE,
        shadow = TRUE
      ),
      f7Button("togglePopup", "Toggle Popup")
     )
   ),
   server = function(input, output, session) {

    output$popupContent <- renderPrint(input$text)

    observeEvent(input$togglePopup, {
     f7Popup(
       id = "popup1",
       title = "My first popup",
       f7Text("text", "Popup content", "This is my first popup ever, I swear!"),
       verbatimTextOutput("popupContent")
      )
    })

    observeEvent(input$popup1, {

     popupStatus <- if (input$popup1) "opened" else "closed"

     f7Toast(
      position = "top",
      text = paste("Popup is", popupStatus)
     )
    })
   }
 )