Last active
June 18, 2022 15:34
-
-
Save mxblsdl/cdfe958f283521dbb9dc41a693012919 to your computer and use it in GitHub Desktop.
Example of using jbox with shiny
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# UI | |
tags$script( | |
src = paste0( | |
"https://cdn.jsdelivr.net/gh/StephanWagner/", | |
"[email protected]/dist/jBox.all.min.js" | |
) | |
), | |
tags$link( | |
rel = "stylesheet", | |
href = paste0( | |
"https://cdn.jsdelivr.net/gh/StephanWagner/", | |
"[email protected]/dist/jBox.all.min.css" | |
) | |
), | |
tags$script( | |
" | |
Shiny.addCustomMessageHandler( | |
type = 'send-notice', function(message) { | |
new jBox('Notice', { | |
content: message, | |
showCountdown: true, | |
autoClose: 4000, | |
color: 'blue', | |
stack: false | |
}); | |
}); | |
Shiny.addCustomMessageHandler( | |
type = 'success-notice', function(message) { | |
new jBox('Notice', { | |
id: 'success', | |
content: message, | |
autoClose: 4000, | |
color: 'green', | |
stack: false | |
}); | |
}); | |
Shiny.addCustomMessageHandler( | |
type = 'fail-notice', function(message) { | |
new jBox('Notice', { | |
id: 'fail', | |
content: message, | |
autoClose: 3000, | |
color: 'red', | |
stack: false | |
}); | |
}); | |
Shiny.addCustomMessageHandler( | |
type = 'load-notice', function(message) { | |
new jBox('Notice', { | |
id: 'loading', | |
content: message, | |
closeButton:true, | |
autoClose:false, | |
color: 'blue', | |
stack: false, | |
responsiveHeight:true, | |
animation: 'slide' | |
}); | |
}); | |
Shiny.addCustomMessageHandler( | |
'resetValue', function(variableName) { | |
Shiny.onInputChange(variableName, null); | |
}); | |
" | |
) | |
) | |
# Server | |
session$sendCustomMessage( | |
type = "load-notice", | |
message = "loading..." | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment