Comments (8)
Hi @stla and thanks for including a reprex with your issue! I've tried your example with shiny 1.7.1, 1.8.0, and the latest version from main
and in all three cases the example seems to be working.
Can you clarify what you mean by "doesn't work anymore"? In my case, I noticed some unusual behavior with the select input not showing the B selection, but the server is correctly registering the choice indicating the the Shiny.bindAll()
might have worked as expected.
from shiny.
It works for you?? For me the observer executing print(input$id)
never prints anything. Also, when I open the console and I look at Shiny.shinyapp.$bindings
, there's only dtable
, not id
.
from shiny.
It works for you?? For me the observer executing
print(input$id)
never prints anything.
Shoot, yeah, I do see this now trying again, sorry. I'm not sure why it looked like it was working before, maybe browser caching. I'll look into this.
from shiny.
@stla after a bit of digging, I've discovered that the issue isn't about async binding but rather about using selectize in this scenario. If you set selectize = FALSE
in the selectInput()
, the select input works as expected. But selectizeInput()
doesn't work when passing through as.character()
.
library(shiny)
ui <- fixedPage(
HTML(as.character(selectInput("id", label = NULL, choices = c("A", "B"))))
)
server <- function(input, output, session) {
observe(print(input$id))
}
shinyApp(ui, server)
The issue is that the selectize dependencies are attached to the element returned by selectInput()
and don't survive the as.character()
coercion. If you want to use selectize as in your reprex, you can include its dependencies somewhere on the page, at which point your example works correctly.
ui <- fluidPage(
br(),
DTOutput("dtable"),
shiny:::selectizeDependency()
)
from shiny.
That behavior hasn't changed recently, so one possibility is that you used this pattern in an app that happened to have another selectInput()
elsewhere on the page and recently used the pattern in app without other select inputs.
from shiny.
Thanks! Alternatively, one can initialize the selectize input with this DT option:
initComplete = JS(c(
"function(settings){",
" $('#id').selectize();",
"}"
))
but in order that it works, one needs to have a selectizeInput
somewhere in the app. We can hide it if we don't want it.
from shiny.
I've found a better way. No need to add a selectizeInput
in the app with this way:
library(shiny)
library(DT)
library(htmltools)
select_input <- selectInput("id", label = NULL, choices = c("A", "B"))
deps <- htmlDependencies(select_input)
dat <- data.frame(
select = as.character(select_input)
)
ui <- fluidPage(
br(),
DTOutput("dtable"),
tagList(deps)
)
from shiny.
Yeah, that general pattern is the way to go if you're coercing a shiny tag
or tagList
to character. I would recommend that you use htmltools::findDependencies()
instead of htmltools::htmlDependencies()
. findDependencies()
recurses into the tag object, whereas htmlDependencies()
reads the dependencies attached to the particular tag or object passed into it.
from shiny.
Related Issues (20)
- Should check for overlapping input and output binding IDs, and only enable error console in local development
- Unnesting an reactive Value to GGplot breaks HOT 1
- reactives running and trigger observers without open the tab
- Shiny is not releasing memory HOT 2
- Can't Open Chrome Driver in shinyapps.io
- Load plot upon launching Shiny app HOT 1
- shiny.autoreload does not work when runApp is given shinyApp result or a list HOT 1
- selectInput not working anymore within renderDataTable in 1.8.0 HOT 2
- Reactive selectizeInput box fail to update correctly in Shiny 1.8.0, first value of previous allowed choices are kept HOT 2
- Update jQuery version to 3.7.1
- 'make' not found HOT 3
- Use req() in checkFunction ReactivePoll HOT 5
- v1.8.0: Unable to highlight multiple selected values at once in selectInput/selectizeInput HOT 1
- Why updateDateInput() nor dateRangeInput() don't have the datesdisabled parameter enabled? HOT 1
- Error in init.ts when using library(jsTreeR) HOT 3
- Shiny server not supporting http range requests. This disables seekbars for locally (www folder) hosted media files. HOT 2
- `accordion_insert_panel` on restored bookmarks does not work with a module HOT 3
- Nginx configuration
- When the withProgress is closed, the program still runs in the background. HOT 3
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 shiny.