Need help with selectors from array
See original GitHub issueI have all my data in an object. I have 3 dropdowns, and I each dropdown to populate based on the selection of the previous one.
For example:
data = {
"campaign1": {
"name": "Campaign 1",
"projects": {
"job A": [
"proj 1"
],
"job B": [
"proj 2",
"proj 3"
]
}
},
"campaign2": {
"name": "Campaign 2",
"projects": {
"job C": [
"proj 4",
"proj 5",
"proj 6"
],
"job D": [
"proj 7",
"proj 8",
"proj 9"
]
}
}
}
The idea is that first you choose a “Campaign”, then 2nd dropdown shows “Jobs” for that campaign, then 3rd shows “Projects” for that job.
This is what I’ve tried for the first 2 items, but I’m not understanding how watch
, enumSource
, and template
work together:
var editor = new JSONEditor(document.getElementById("editor"), {
...
schema: {
type: "object",
properties: {
campaign: {
id: "campaign",
type: "string",
enumSource: [{
source: Object.entries(data),
value: "{{item.0}}",
title: "{{item.1.name}}"
}],
},
project: {
type: "string",
watch: { "c": "campaign" },
enumSource: [{
source: Object.entries(data),
title: "{{item[c].projects}}"
}]
....
The first item shows the campaigns correctly, but how do I then use that selection to populate the 2nd dropdown?
Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Comments:13
Top Results From Across the Web
array-selector – API Reference - Polymer Project
Custom element that links paths between an input `items` array and an output `selected` item or array based on calls to its selection...
Read more >javascript - Selectors-based search through an array of elements
I have a pre-selected list of Node objects, and I want a function that could take the same selectors parameter, but search inside...
Read more >DOM Selectors and Their Array-Like Objects | by Kelly M.
Before we dive into the selectors themselves, it is crucial that we understand what they give back to us are not arrays, but...
Read more >Document.querySelectorAll() - Web APIs | MDN
A non-live NodeList containing one Element object for each element that matches at least one of the specified selectors or an empty NodeList...
Read more >[Solved] Selectors As Arrays - Help with OR-groups
You'll need to use the "verbose" version of a selector array. Ryan gives an example of a verbose selector array this in this...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
btw, I just ran
cloc
against Alpaca’ssrc
and
json-editor
Watching a field from within the schema is rather limited, compared to watching the field from JavaScript. If you watch the field(s) from JavaScript, you can manipulate the fields better. Take a look at this example: https://github.com/json-editor/json-editor/wiki/Adding-autoprefilling-based-on-value-in-another-field-using-Bloodhound