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

Not able to update json if there are multiple JSONeditor #40

Closed
ankurtechelogy opened this issue May 29, 2019 · 12 comments
Closed

Not able to update json if there are multiple JSONeditor #40

ankurtechelogy opened this issue May 29, 2019 · 12 comments
Labels
question Further information is requested

Comments

@ankurtechelogy
Copy link

No description provided.

@mariohmol
Copy link
Owner

Hi.. can u describe more this issue?

the demo is working with 2 json editors with no issues

https://stackblitz.com/edit/ang-jsoneditor

@mariohmol mariohmol added the question Further information is requested label Jun 19, 2019
@mariohmol
Copy link
Owner

if u still have this issue... let us know

@osmanraifgunes
Copy link
Contributor

osmanraifgunes commented Feb 3, 2020

I have the same problem. If the there is multiple editors (created by ng-for loop) the events are not firing correctly.

Always first editors parameters are passed to bound function of the event.

@mariohmol
Copy link
Owner

please provide an stackblitz code or something to test this behavuour?

@mariohmol mariohmol reopened this Feb 5, 2020
@mariohmol
Copy link
Owner

Hi.. @osmanraifgunes with the #58 fixes this issue? can u make a demo with this behaviour so we can fix that?
thanks!

@osmanraifgunes
Copy link
Contributor

osmanraifgunes commented Feb 11, 2020

Here is the example : https://stackblitz.com/edit/ang-jsoneditor-easjts?file=src/app/app.component.html

Both editors trigger event, but the data is always the first one's data. I think problem is the ang-jsoneditor module works as singleton.

@mariohmol
Copy link
Owner

thanks for that info!!

what u mean about working as singleton?

do u have any ideas how to fix this?

@mariohmol
Copy link
Owner

The thing here is about reusing the same editorOptions..

in you case what i did to fix was:

<json-editor [options]="makeOptions()" [data]="prd" (change)="showJson($event)"></json-editor>
  makeOptions = () => {
    return new JsonEditorOptions();
  }

@osmanraifgunes
Copy link
Contributor

osmanraifgunes commented Feb 11, 2020

I think solution is using @ViewChildren instead of @ViewChild. I asked this on stackof : https://stackoverflow.com/questions/60040466/angular-component-multiple-instance-binding-input-problem

But doing so is writing this module whole again.

mariohmol added a commit that referenced this issue Feb 11, 2020
@mariohmol
Copy link
Owner

I included this solution in the docs and in the demo app as well.. see if that works in your side

@SahilMahadwar
Copy link

Hi how can we add options when we use
makeOptions = () => {
return new JsonEditorOptions();
}

@mariohmol
Copy link
Owner

Hi you can add this way.

Just updated the docs with it

makeOptions = () => {
  const options = new JsonEditorOptions();
  options.modes = ['code', 'text', 'tree', 'view'];
  return options;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants