Yang-Tang / shinyjqui

jQuery UI Interactions and Effects for Shiny
https://yang-tang.github.io/shinyjqui/
Other
273 stars 32 forks source link

OrderInput returns the items and then NULL #29

Closed zameji closed 6 years ago

zameji commented 6 years ago

Instead of just the items, orderInput returns the items and NULL. Smalles working example:

library(shiny) library(shinyjqui)

shinyApp( ui = fluidPage( orderInput('ns', 'Numbers', items = c("A", "B", "C"), as_source = FALSE, width="100%", item_class="primary", placeholder="Numeric variables"), actionButton("save", "Save") ), server = function(input, output) { vals <- reactiveValues(v=NULL) observeEvent(input$save, {vals$v <- input$ns_order print(str(vals$v)) }) } )

Yang-Tang commented 6 years ago

Hi @zameji, you may notice print(str(c("A", "B", "C"))) also returns additional NULL. This is because function str() works by its side effect (output to the terminal) and return nothing (NULL), and function print() print out the NULL returned by str(), so you will see the items output by str() first, then a NULL by print().

zameji commented 6 years ago

Hi @Yang-Tang, thank you for the clarification! I was wondering where does the NULL come from and why is it listed after the actual str() output. Now that's clear. Sorry for the false alarm!