Comments (16)
With a little JavaScript, argument html
is back !
Glad you find the package useful :)
Try :
library("shiny")
library("shinyWidgets")
shinyApp(
ui = fluidPage(
tags$h1("Click the button"),
actionButton(
inputId = "sw_html",
label = "Sweet alert with HTML"
)
),
server = function(input, output, session) {
observeEvent(input$sw_html, {
sendSweetAlert(
session = session,
title = "Success !!",
text = tags$span(
"In", tags$b("bold"), "and", tags$em("italic"),
tags$br(),
"and",
tags$br(),
"line",
tags$br(),
"breaks"
),
html = TRUE,
type = "success"
)
})
}
)
Victor
from shinywidgets.
have you installed the dev version of shinyWidgets?
library(devtools)
install_github("dreamRs/shinyWidgets")
from shinywidgets.
the dev version is shinyWidgets_0.4.1.910. Try to remove it and re-install using the code I provided above.
from shinywidgets.
You have to use argument text
to use HTML, and if yous use raw HTML, you'll have to escape it with HTML
like this :
library("shiny")
library("shinyWidgets")
ui <- fluidPage(
actionButton(
inputId = "go",
label = "Launch confirmation dialog"
)
)
server <- function(input, output, session) {
observeEvent(input$go, {
sendSweetAlert(
session = session, type = "warning", title = NULL,
text = HTML("Is the HTML </br>Working or not?"), html = TRUE
)
})
}
shinyApp(ui = ui, server = server)
from shinywidgets.
Hello,
This option is no longer available in sweetalert 2.0, I'll look to find an alternative solution.
I added argument closeOnClickOutside
to prevent closing when clicking outside, please install package from Github :
shinyApp(
ui = fluidPage(
tags$h1("Click the button"),
actionButton(
inputId = "success",
label = "Launch a success sweet alert"
)
),
server = function(input, output, session) {
observeEvent(input$success, {
sendSweetAlert(
session = session,
title = "Success !!",
text = "All in order",
type = "success",
closeOnClickOutside = FALSE
)
})
}
)
from shinywidgets.
Amazing! Very nice features thank you.
Romain
from shinywidgets.
Yes, it works in the latest version. I tried to go further by passing input/output, it seems to work but I don't know if it is very robust. Thanks for the improvement suggestion, it was cool to do.
If you want to try it :
library("shiny")
library("shinyWidgets")
library("ggplot2")
shinyApp(
ui = fluidPage(
tags$h1("Click the button"),
actionButton(
inputId = "sw_html",
label = "Sweet alert with ggplot"
),
tags$style(".swal-modal {width: 70%;}")
),
server = function(input, output, session) {
observeEvent(input$sw_html, {
sendSweetAlert(
session = session,
title = "Yay an histogram!",
text = tags$div(
plotOutput(outputId = "plot"),
sliderInput(
inputId = "slider", label = "Number of bins",
min = 20, max = 90, value = 60, width = "100%"
)
),
html = TRUE
)
})
output$plot <- renderPlot({
ggplot(diamonds, aes(carat)) +
geom_histogram(bins = input$slider)
})
}
)
from shinywidgets.
you rock! This is really a good package thanks for all your updates.
from shinywidgets.
I confirm the problem is fixed using:
devtools::install_github("dreamRs/shinyWidgets")
as well as paracetamol ^_^
Cheers
from shinywidgets.
Hello,
thank you very much for your update and thanks for the package it is very useful!
from shinywidgets.
just updated R and shinyWidgets, this example throws:
Warning: Error in sendSweetAlert: unused argument (html = FALSE)
Stack trace (innermost first):
68: observeEventHandler [#11]
4:
3: do.call
2: print.shiny.appobj
1:
from shinywidgets.
yes just did, still same result
sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=Dutch_Netherlands.1252 LC_CTYPE=Dutch_Netherlands.1252 LC_MONETARY=Dutch_Netherlands.1252 LC_NUMERIC=C
[5] LC_TIME=Dutch_Netherlands.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shinyWidgets_0.4.1 shiny_1.0.5
loaded via a namespace (and not attached):
[1] compiler_3.4.3 R6_2.2.2 htmltools_0.3.6 tools_3.4.3 Rcpp_0.12.15 jsonlite_1.5 digest_0.6.14 xtable_1.8-2 httpuv_1.3.5 mime_0.5
from shinywidgets.
Have you plan to do the same on the confirmSweetAlert
function? I realy like the way it can be customized using HTML and the possibility to force a click from the user.
from shinywidgets.
maybe it's a problem on my side but the htlm = T
option on the confirmSweetAlert
and the sendSweetAlert
didn't seem to work anymore on version 0.4.1.950
Here is a minimal example:
library("shiny")
library("shinyWidgets")
ui <- fluidPage(
actionButton(
inputId = "go",
label = "Launch confirmation dialog"
)
)
server <- function(input, output, session) {
observeEvent(input$go, {
sendSweetAlert(
session = session, type = "warning",
title = "Is the HTML </br>Working or not?",html = T
)
})
}
shinyApp(ui = ui, server = server)
}
from shinywidgets.
Hi Victor!
I noticed that it does not work on shiny-server pro:
Warning: Error in sendSweetAlert: unused argument (html = FALSE)
Stack trace (innermost first):
65: observeEventHandler [/srv/shiny-server/case_studies_app_V3.2/server.R#485]
1: runApp
no matter if it is set to TRUE or FALSE
Removing sendSweetAlert from the observeEvent would solve the problem. But this is not what I want to do :)
from shinywidgets.
Hello David,
Yes I removed the arg on the last CRAN release, bad idea...
It's back in the dev version, try re-install the package from Github.
I'll try release to CRAN tomorrow.
Victor
from shinywidgets.
Related Issues (20)
- pickerInput and bslib with bootstrap version 5 - Deselection does not work if 'maxOptions = 1' HOT 2
- materialSwitch label issue HOT 2
- [Feature Request]Listbox with multi-select function and sorting function
- [BUG]When using lapply() to batch generate dropMenu, it doesn't work very well HOT 2
- Why does pickerInput liveSearch option not work? HOT 2
- How to avoid useShinydashboard() change any CSS HOT 1
- Remove !important rule inline in searchInput() HOT 1
- Dropdown closes after running updatePickerInput HOT 1
- AirDatepickerInput: Сhanging the date from the keyboard in the input does not update the calendar HOT 1
- `pickerInput` ADA improvements HOT 1
- `numericRangeInput` ADA improvements HOT 3
- airDatepicker shifts time by loosing timezone information
- setShadow deprecation warning shows up in UI HOT 1
- Screen moves when confirmSweetAlert is closed. HOT 1
- pickerGroupUI() breaks in bslib HOT 7
- `materialSwitch` label not centered vertically with switch in `bs4dash` HOT 1
- add timezone option to airdatepicker
- ShinyWidgets - updateAirDateInput
- pickerInput: strange behaviour with disabling individual options when some are grouped HOT 2
- updateProgressBar shows [object Object] when title is of class shiny.tag HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shinywidgets.