Skip to content

Instantly share code, notes, and snippets.

@richarddmorey
Last active November 29, 2017 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richarddmorey/6e1e3123e53faf1a620d63ea68a1844b to your computer and use it in GitHub Desktop.
Save richarddmorey/6e1e3123e53faf1a620d63ea68a1844b to your computer and use it in GitHub Desktop.
example for shinyjs
---
runtime: shiny
---
```{r echo=FALSE, message=FALSE, warning=FALSE}
require(shinyjs)
useShinyjs(rmd=TRUE)
observe({
updateTextInput(session, 'ID', value = "Updated.")
disable('ID')
})
textInput("ID", label = "ID:", width = "150px", placeholder = "ID", value = "Not updated.")
```
---
title: "Test session variables"
output:
flexdashboard::flex_dashboard:
orientation: row
runtime: shiny
---
```{r}
require(flexdashboard)
require(shinyjs)
useShinyjs(rmd=TRUE)
```
```{r}
observe({
query = getQueryString()
ID = query[['ID']]
active = query[['IDactive']]
if (!is.null(ID)) {
updateTextInput(session, 'ID', value = ID)
}
if(!is.null(active)){
if(active == '0'){
disable('ID')
}
}
})
```
Column {.sidebar}
-----------------------------------------------------------------------
```{r}
textInput("ID", label = "ID:", width = "150px", placeholder = "ID", value = "hi")
```
Row {data-height=60}
------------------------------------
### Other
Row
-------------------------------------
### Query string
```{r}
renderUI({
query <- getQueryString()
return(HTML(jsonlite::toJSON(query)))
})
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment