Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select api & update json based on schema of item returned #802

Closed
tkuben opened this issue Nov 20, 2017 · 1 comment
Closed

Select api & update json based on schema of item returned #802

tkuben opened this issue Nov 20, 2017 · 1 comment

Comments

@tkuben
Copy link

tkuben commented Nov 20, 2017

Hi All,

I would like to have an enumSource reference an API which pulls the list of items. Each item in the list contains a schema of its own. Upon change, I would like to append to the select box, the schema that they have chosen to allow the user to enter values for it. I have updated my jsoneditor code with the following pull request: #720 and made my own changes. Now, on the onChange portion of the select, I have the following:

onInputChange: function() {
  var val = this.input.value;

  var editor = this.jsoneditor.getEditorClass(this.enumSource[0].source[val].schema);

  var ret = this.jsoneditor.createEditor(editor,{
    jsoneditor: this.jsoneditor,
    schema: this.enumSource[0].source[val].schema,
    container: this.container,
    path: this.path,
    parent: this
  });
  ret.preBuild();
  ret.build();
  ret.postBuild();

This successfully pulls the schema of the item and appends to the select box, however it is not updating the global json editor with the new schema I've added. It only contains the select box but not the item I have chosen. How can I register this such that the item's schema I have selected is also included into the global schema?

Thank you
Cheers,
TJ

@tkuben
Copy link
Author

tkuben commented Nov 21, 2017

I've implemented this feature in my own fork of the project for those that are interested: https://github.com/tkuben/json-editor/commits/master

@tkuben tkuben closed this as completed Nov 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant