-
Notifications
You must be signed in to change notification settings - Fork 88
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
implementing callbacks for onChangeJSON is problematic... #52
Comments
Hi! Thanks for that.. i'm just kind lost about what is your suggestion.. what should we do here? |
Hi @osmanraifgunes , can u tell me if #58 fixes this? |
No it does not.I solved this problem by editing original jsoneditor. But it is a temporary solution. |
did u open an issue on jsoneditor repo? if u can link it here.. |
No I did not open. In fact it is not their bug. I just wangled that component. Problem is in ang-jsoneditor component. |
Well.. as we can see here https://github.com/josdejong/jsoneditor/blob/9e9fd72eddafe9c8da88be032571e10c860220e9/src/js/previewmode.js#L333 and here
They act as the same as the original repo.. to be honest I dont see this expected behaviour at the original repo... Am I missing something? |
Describe the bug
I've implemented the editor with the angular wrapper, and have specified functions for onChange and onChangeJSON. onChange can be bound within the template, whereas onChangeJSON cannot, so I've added it to the editorOptions object.
At runtime, the value provided in the onChangeJSON callback is the entire json object, rather than the more fine grained values suggested by the documentation. What's more, the closure context of the function is the options object, rather than the component. I've addressed that by defining the options object like so:
This results in a somewhat odd way to access the editor in the callback:
Also, the get method returns the entire json, rather than the finer grained value that had changed.
Expected behavior
onChangeJSON should behave as suggested in the json-editor documentation:
"Set a callback function triggered when the contents of the JSONEditor change. Passes the changed contents as a JSON object."
Is this a bug, an implementation issue, or something else?
Console and Error stack trace
No error.
Desktop (please complete the following information):
"@angular/core": "~8.2.2",
"ang-jsoneditor": "^1.8.2",
"jsoneditor": "^6.2.1",
The text was updated successfully, but these errors were encountered: