This message was deleted.
# help
s
This message was deleted.
j
Not sure if I got your example right. I tried to come up with a minimal working example, using a list in
R
for the paths to the images:
Copy code
```{r}
fig_list <- list(
    "kitten a" = "<https://cdn.pixabay.com/photo/2019/11/08/11/56/kitten-4611189_1280.jpg>",
    "kitten b" = "<https://cdn.pixabay.com/photo/2016/03/28/10/05/kitten-1285341_1280.jpg>",
    "kitten c" = "<https://cdn.pixabay.com/photo/2017/07/25/01/22/cat-2536662_1280.jpg>"
)
ojs_define(fig_list)
Copy code
{ojs}
viewof file = Inputs.select(Object.keys(fig_list), {label: "Choose feature"})
Copy code
{ojs}
html`<img src="${fig_list[file]}" />`
```
R
lists seem to get converted to objects in javascript. That might be one issue with your code: I think Inputs.select expects an array. Also, the
viewof
and the html for the
<image>
need to be in separate observable cells 🙂 Does this help?
f
I think Inputs.select expects an array.
Small clarification, Inputs.select accepts an iterable. It works best with Maps where it will automatically handle key and value. To avoid having to provide the format and valueof options, pass your object in as
new Map(Object.entries(obj))
.
🙏 1
n
Thanks to both of you with valuable inputs! The reason that I was trying to print the variable was to troubleshoot another error (non-functional drop-down list). Now I could fix it there were issues in structure of the qmd file which I could not figure out what it was but I used a template to fix that. Anyhow, I learnt from your feedbacks, Thanks!