Comments (8)
Here's a select2 example:
- Demo: https://json-editor.github.io/json-editor/select2.html
- Source: https://github.com/json-editor/json-editor/blob/master/docs/select2.html
If you use tags
-style you need type: array
, I think ... simple example
from json-editor.
@schmunk42 , In your example same console error output
{
"title": "Person",
"type": "object",
"properties": {
"tags": {
"type": "array",
"format": "select2",
"uniqueItems": true,
"items": {
"type": "string",
"enum": [
"bold",
"italic",
"smallcaps"
]
}
}
}
}
jsoneditor.getEditor('root.tags').setValue(['dddddd1'])
// OR
jsoneditor.getEditor('root.tags').setValue('dddddd2') // same error
// OR
jsoneditor.setValue({'tags':'fffffff3'}) // same error
// OR
jsoneditor.setValue({'tags':['fffffff4'] }) // same error
jsoneditor.min.js:8 Uncaught TypeError: this.input.appendChild(...).trigger is not a function
at a.value (jsoneditor.min.js:8:145371)
at a.value (jsoneditor.min.js:8:144911)
at a.value (jsoneditor.min.js:8:143747)
at <anonymous>:1:35
from json-editor.
It shows the error you mentioned if you use a non-exisiting value, but with an existing value it looks good to me:
from json-editor.
I know there's no problem using existing values... I was reporting an BUG when setvalue a non-existent value ...
BTW, origin Select2 supports non-existent value when using tags=true.
@schmunk42
from json-editor.
Funny thing is, in the example you can enter a custom value, click twice ... first click show the error, second click adds the value.
However, a validation error is still triggered because the value is not contained in the enumeration list.
I think you'd need a custom editor which saves the values as comma-separated string.
from json-editor.
i already known :( .......
source code not quote $ the appendChild(xxx).trigger(xx)...
json-editor/src/editors/select2.js
Line 77 in 98f85cd
json-editor/src/editors/array/select2.js
Line 82 in 98f85cd
fix to
// this.input.appendChild(new Option(sanitized, sanitized, false, false)).trigger('change')
$(this.input.appendChild(new Option(sanitized, sanitized, false, false))).trigger('change')
@schmunk42 please fix it.
from json-editor.
@germanbisurgi Please have a look and reopen if it's a bug.
from json-editor.
@schmunk42 @germanbisurgi anyone check it?
from json-editor.
Related Issues (20)
- Can I Do Dependencies Only On the Default Value And Enum? HOT 1
- Starrating format isn't working properly HOT 1
- bug/regression: bool or number value does not show when remove_empty_properties=true and use_default_values=false
- Can Do a "WACTH" To Another Root "JSON Editor". HOT 4
- Auto generate schema for simple cases HOT 5
- Support for chained / nested watch HOT 2
- Add meta-data (schema builder) example HOT 1
- Validation of datetime-local fails when oneOf is used HOT 3
- An error occurs when a dependency is defined after the field that depends on it HOT 1
- Dependent field does not update when watched field changes HOT 1
- Failure to parse schema with "default": null due to unhandled exception in browser console
- select2 doesn't refer enumSource of item in array. HOT 12
- How do I add my syntax highlighting to Ace Editor? HOT 1
- test
- Enum wont be selected on load if it not the first element HOT 2
- Dependencies with false values not fullfilled HOT 1
- Adding a property breaks UI with a couple of exceptions in the console
- Cannot set (programmatically) value for "enum" string HOT 2
- compare fields HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json-editor.