Comments (5)
+1
I like the concept and I'd like to take a shot at a custom editor but I could use a tutorial or better documentation.
from json-editor.
I've started filling out the wiki (https://github.com/jdorn/json-editor/wiki) with more in-depth documentation. I haven't documented custom editors yet, but the notes on overall code structure may still be helpful.
from json-editor.
+1
I have a pretty annoying problem with a (simple) custom editor. It doesn't work great with validate
and getValue
on the global form object.
I update the this.value
variable of the editor correctly (use console.log to make sure) when the user fills the form, yet when I use one of the two functions mentioned above, the value for the editor is null or undefined.
BUT if the users changes another value on the form that uses a default editor, the next getValue
or validate
call will return the right value for my custom editor.
I have noticed in default editors code that you often use this portion of code:
this.jsoneditor.notifyWatchers(this.path);
if(this.parent) this.parent.onChildEditorChange(this);
else this.jsoneditor.onChange();
So I tried it and it worked. The problem is that if my schema has an array with the items
schema set to a custom editor, it generates an error on the editor of the first item of the table, whereas there is no first item.
I don't know if I explained my problem correctly, but my final question is:
[TL:DR] How to update a custom editor's value correctly ?
Edit: I replaced the problematic code above with
if(this.jsoneditor) {
this.jsoneditor.notifyWatchers(this.path);
if(this.parent) this.parent.onChildEditorChange(this);
else this.jsoneditor.onChange();
}
and it seems to work fine now.
from json-editor.
@SebT thank you so much!!!
from json-editor.
I started documenting the editor class in the wiki - https://github.com/jdorn/json-editor/wiki#editor-srceditorjs
The solution @SebT has is slightly out of date. It should be replaced with just this.onChange(true)
. I recommend reading through the wiki which goes through the major editor methods and what is supposed to happen in each.
from json-editor.
Related Issues (20)
- Validation schema - only defined elements HOT 1
- Feature request HOT 1
- How do I extend json-editor to support new field types
- JSON Editor Very Slow HOT 1
- how to prevent(disable) cache HOT 1
- Can I format checkbox for one item per line HOT 1
- readonly is not documented HOT 1
- is there any typescript version available of json-editor?
- Is there a way to input previously generated json data and have the editor populate the fields? HOT 1
- Does the Schema support variable
- enum field selection based on watch of another field
- choose objects in array HOT 1
- Q: How do you make a checkbox required?
- minItems causing script error
- Can I input multi-language attributes?
- "Value must validate against one of the provided schemas"
- Checkbox disabled by default?
- I have a field in the schema, but in startVal it doesnot have HOT 4
- Angular How to send default configuration ?
- Difference between anyOf ,oneOf, allOf
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.