popups don't work anymore with shiny 0.9.1

428 views
Skip to first unread message

Stéphane Laurent

unread,
Mar 21, 2014, 4:47:03 AM3/21/14
to shiny-...@googlegroups.com
Hi,

With shiny 0.8 I had some popups which worked fine like this:

<a href="#" data-toggle="popover" title="Estimates of intercept and slope" data-content="Estimate of intercept/slope." data-animation="true" data-placement="top" data-trigger="hover">Estimate</a>

But now with shiny 0.9.1 only the title of the popup appear, the content doesn't appear anymore.


Stéphane Laurent

unread,
Mar 21, 2014, 5:02:27 AM3/21/14
to shiny-...@googlegroups.com
With this example the content appears: 

                                                    helpPopup("Import a data file", 
                                                              includeMarkdown("../helpPopups/help_upload.md"), 
                                                              placement='right', 
                                                              trigger='hover'
                                                    )

the markdown file help-upload.md is : 

You can import data in *csv*, *xls*, or *xlsx* format. If you use *xls(x)* then the first sheet will be imported. 

But the html code appears in the content, that is, one sees "<p> You can import data in <em>csv>/em> ............." in the popup. 

The helpPopup() function is : 

helpPopup <- function(title, content,
                      placement=c('right', 'top', 'left', 'bottom'),
                      trigger=c('click', 'hover', 'focus', 'manual')) {
  tagList(
    singleton(
      tags$head(
        tags$script("$(function() { $(\"[data-toggle='popover']\").popover(); })")
      )
    ),
    tags$a(
      href = "#", `data-toggle` = "popover", # class = "btn btn-mini", 
      title = title, `data-content` = content, `data-animation` = TRUE,
      `data-placement` = match.arg(placement, several.ok=TRUE)[1],
      `data-trigger` = match.arg(trigger, several.ok=TRUE)[1],
      
      tags$i(class="icon-question-sign")
    )
  )
}


Familie Gieshoff

unread,
Mar 21, 2014, 6:36:11 AM3/21/14
to shiny-...@googlegroups.com
Dear all,

do you know the trick, how one can avoid to see the HTML code. The popup works perfectly in shiny0.8, the HTML code in the text is a pity.

Best regards,

Jürgen

PS: As always, the update to shiny 0.9.1 is great !! Thank you very much for this nice package!

Stéphane Laurent

unread,
Mar 21, 2014, 1:36:20 PM3/21/14
to shiny-...@googlegroups.com
I have not tried yet but perhaps we need to put an argument like data-html=true

Familie Gieshoff

unread,
Mar 22, 2014, 5:06:12 AM3/22/14
to shiny-...@googlegroups.com
Dear Stéphane,

Thank you very much for the hing. It works perfectly.

Best regards,
Jürgen

Stéphane Laurent

unread,
Mar 23, 2014, 3:40:17 PM3/23/14
to shiny-...@googlegroups.com

1) Right. Adding `data-html`="true" in the helpPopup() function works fine.

2) But the popup in the following app works fine with shiny 0.8 whereas it doesn't work with shiny 0.9 (only the title appears). Any idea ?

tabl <- function(){
  title <- "hello"
  content <- "Goodbye"
  out <- sprintf('<table style="width:300px">
  <tr>
    <td><a href="javascript: void(0)" data-toggle="popover" data-content="%s" data-html="true" data-animation="true" data-placement="bottom" data-trigger="hover" title="%s">Jill</a></td>
    <td>Smith</td> 
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td> 
    <td>94</td>
  </tr>
</table>
', title, content)
  out <- tagList(
    singleton(
      tags$head(
        tags$script("$(function() { $(\"[data-toggle='popover']\").popover(); })")
      )
    ),
    HTML(out)
  )
  return(out)
}

runApp(
  list(
    ui=pageWithSidebar(
      headerPanel(""),
      sidebarPanel(
      ),
      mainPanel(
        uiOutput("htmltable")
      )
    ),
    server=function(input,output,session){
      output$htmltable <- renderUI({ tabl() })
    })
)

Stéphane Laurent

unread,
Mar 25, 2014, 5:44:39 AM3/25/14
to shiny-...@googlegroups.com

Claude Boivin

unread,
Apr 7, 2014, 9:31:08 PM4/7/14
to shiny-...@googlegroups.com
Hello Stéphane,
You may want to try this code with Shiny 0.9.1. I have tested it with your example and it works well on my side.

Here is the helpPopup function, with some improvements:

# popup function (from J. Cheng, Shiny-discuss, 2/7/13)
# C Boivin:  add a parameter "glue" to label the button
# or to place an object on (button, selectInput, slider)
helpPopup <- function(title, content,
              placement=c('right', 'top', 'left', 'bottom'),
              trigger=c('click', 'hover', 'focus', 'manual'),
              glue = NULL) {
  
  tagList(
    singleton(
      tags$head(
           tags$script("$(function() { $(\"[data-toggle='popover']\").popover(); })")
      )
    ),
    tags$a(
    #  href = "#", class = "tip", `data-toggle` = "popover",
      href = "#",
      class = "btn btn-default", 
      `data-toggle` = "popover",
      title = title, 
      `data-content` = content,
      # added this parameter
      `data-html` = TRUE, 
      # 
      `data-animation` = TRUE,
      `data-placement` = match.arg(placement, several.ok=TRUE)[1],
      `data-trigger` = match.arg(trigger, several.ok=TRUE)[1],  
       glue, 
      tags$i(class="icon-info-sign")
    ),
    # CB added for popup width control
    tags$style(type='text/css', ".popover { width: 400px; relative; left: 320px !important; }")
    # end add
  )
}

ui code:
shinyUI(pageWithSidebar(
  headerPanel("Popup examples"),
  sidebarPanel(
    wellPanel(
    # first example
      helpPopup("Import a data file", 
      includeMarkdown("www/helpPopups/help_upload.Rmd"), 
    #  you may also use: includeHTML("your-file.html"),
    #  you may also  link your html file with a .css stylesheet 
      placement='right', 
      trigger='click', 
      glue = " click on popup"
      )
    ),  
   wellPanel(
      # second example
      helpPopup("Glue the help on something", 
      includeMarkdown("www/helpPopups/help_upload.Rmd"), 
     placement='right', 
     trigger='hover', 
     glue =  selectInput("sel1", "", 
        choices = c("first choice, a long text to enlarge this box", 
                   "second choice",
                    "third choice"),
       selected = "first choice")
     # you may also glue the help on a button: glue = actionButton()
    )
    )
  ),
  mainPanel(  
  )
))

server.R code
source('~/your_path_to_the_helpPopup_function/HelpPopup.R')

shinyServer(function(input,output,session){
})

Le mardi 25 mars 2014 05:44:39 UTC-4, Stéphane Laurent a écrit :

Familie Gieshoff

unread,
Feb 24, 2015, 5:40:17 AM2/24/15
to shiny-...@googlegroups.com
Dear all,

I am coming back to this "old" thread....

I was using the helpPopoup function over the last versions of shiny, but it seems that shiny 0.11 does not support the function anymore.

Here is the code for your review:


helpPopup <- function(title, content,
                      placement=c('right', 'top', 'left', 'bottom'),
                      trigger=c('click', 'hover', 'focus', 'manual')) {

  tagList(
    singleton(
      tags$head(
        tags$script("$(function() { $(\"[data-toggle='popover']\").popover(); })")
      )
    ),
    tags$a(
      href = "#", class = "", `data-toggle` = "popover",
      title = title, `data-content` = content, `data-animation` = TRUE,`data-html` = TRUE,

      `data-placement` = match.arg(placement, several.ok=TRUE)[1],
      `data-trigger` = match.arg(trigger, several.ok=TRUE)[1],
      tags$i(class="icon-question-sign")
    )
  )
}

I would be very happy to get any ideas.....

Thank you in advance

Jürgen

____________

R version 3.1.2 (2014-10-31)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252    LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C                    LC_TIME=German_Germany.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_1.0.0 plyr_1.8.1    shiny_0.11.1 

loaded via a namespace (and not attached):
 [1] colorspace_1.2-4 digest_0.6.8     grid_3.1.2       gtable_0.1.2     htmltools_0.2.6  httpuv_1.3.2     MASS_7.3-35     
 [8] mime_0.2         munsell_0.4.2    proto_0.3-10     R6_2.0.1         Rcpp_0.11.4      reshape2_1.4.1   RJSONIO_1.3-0   
[15] scales_0.2.4     stringr_0.6.2    tools_3.1.2      xtable_1.7-4    



Reply all
Reply to author
Forward
0 new messages