-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MathJax not working with choices inside selectInput and selectizeInput #1506
Comments
Have you or anyone found a workaround. Im struggeling with the same... |
There's a way to do this if you use HTML (instead of MathJax) and some JS in the library(shiny)
greekNames <- list("alpha", "beta", "gamma", "delta", "epsilon")
greekCodes <- list("α", "β", "γ", "δ", "ε")
greek <- setNames(greekNames, greekCodes)
ui <- fluidPage(
selectizeInput("select", label = "Select", choices = NULL),
textOutput("txt")
)
server <- function(input, output, session) {
updateSelectizeInput(
session, "select",
choices = greek,
options = list(render = I("
{
item: function(item, escape) { return '<div>' + item.label + '</div>'; },
option: function(item, escape) { return '<div>' + item.label + '</div>'; }
}
"))
)
output$txt <- renderText({
paste("You chose", input$select)
})
}
shinyApp(ui, server) FYI, if you don't mind using library(shiny)
greekNames <- list("alpha", "beta", "gamma", "delta", "epsilon")
greekCodes <- list("α", "β", "γ", "δ", "ε")
greekHtml <- lapply(greekCodes, HTML)
ui <- fluidPage(
checkboxGroupInput("box", "Choose one or more greek letters",
choiceNames = greekHtml,
choiceValues = greekNames
),
radioButtons("radio", "Choose one greek letter",
choiceNames = greekHtml,
choiceValues = greekNames
),
textOutput("selected_boxes"),
textOutput("selected_buttons")
)
server <- function(input, output, session) {
output$selected_boxes <- renderText({
paste("Checkboxes: you chose", paste(input$box, collapse = ", "))
})
output$selected_buttons <- renderText({
paste("Radio buttons: you chose", input$radio)
})
}
shinyApp(ui, server) |
FYI, the math rendering works fine with
|
I want to create a dropdown menu with the choices containing math symbols, but it seems MathJax does not work with labels of choices inside
selectInput
andselectizeInput
.This is the minimal code using
selectizeInput
:After the page first loads, MathJax works for the selected item, but not the choices.
After another choice other than default is selected, MathJax stops working for the selected item.
The same goes for
selectInput
.The text was updated successfully, but these errors were encountered: