Yang-Tang / shinyjqui

jQuery UI Interactions and Effects for Shiny

Home Page:https://yang-tang.github.io/shinyjqui/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use orderInput in Table & module

emantzo opened this issue · comments

I am having some difficulties in using orderInput to define formulas in aTable.
Would you please check my SO question?

Many thanks!!

Hi @emantzo , this is related to a bug of shinyjqui, which was fix just now in 948af5e. Now you can use the reset button like this:

library(shiny)
library(shinyjqui)

ui <- fluidPage(
  orderInput("ops", "Operators", c("~", "+", "*"),
             as_source = T, connect = "formula", 
             item_class = "primary"),
  orderInput("var", "Variables", c("x", "y", "z"), 
             as_source = F, connect = "formula", 
             item_class = "default",
             placeholder = "(blank)"),
  orderInput("formula", "Formula", items = NULL,
             as_source = F, connect = NULL, placeholder = "(build your formula)"),
  verbatimTextOutput("myFormula"),
  actionButton("reset", "Reset")
)

server <- function(input, output, session) {
  # on page load, save the two orderInput
  jqui_sortable("#var,#formula", operation = "save")
  observeEvent(input$reset, {
    jqui_sortable("#formula,#var", operation = "load")
  })
  output$myFormula <- renderPrint({
    paste0(input$formula, collapse = " ")
  })
}

shinyApp(ui, server)

You need to install the newest github version of shinyjqui in which I fixed the bug. To remove certain items, you may try the updateOrderInput function.