Hi! I've made lots of custom shiny inputs but they've always returned a single value or a vector. I was wondering what the structure of my JS would need to be in order to return a list?
..... //shiny input binding
getValue: function getValue(el) {
var value = [
{id :1, name:"a" },
{ id:2, name:"b"},
{ id:3, name"c"}
]
return value
},
Desired Output
print(input$mything)
[[1]]
[[1]]$id
[1] 1
[[1]]$name
[1] "a"
[[2]]
[[2]]$id
[1] 2
[[2]]$name
[1] "b"
[[3]]
[[3]]$id
[1] 3
[[3]]$name
[1] "c"
What I'm getting right now:
id name id name id name
"1" "a" "2" "b" "3" "c"
Bonus question! Can I give this list attributes so I can return something else from JS back to r but my user doesn't have to see it? What would that look like?
..... //shiny input binding
getValue: function getValue(el) {
var attr = "test"
var value = [
{id :1, name:"a" },
{ id:2, name:"b"},
{ id:3, name"c"}
]
return value
},
So input$mything
would return the same thing or something similar to this?
dummy_input <- list(list(id = 1, name = "a"),
list(id = 2, name = "b"),
list(id = 3, name = "c")
)
attr(dummy_input, 'custom_attr') <- "test"