Closed germanbisurgi closed 5 years ago
@germanbisurgi Is this just a thing of this widget or would it require also changes in json-editor
?
CC: @pmk65 this is just FYI
it will affect only the yii2-json-editor/src/JsonEditorWidget.php file
@dmstr/developers If there's feedback from your side, raise your voice.
Otherwise @germanbisurgi ... go ahead ;)
Isn't that feature already available or am I missing something? In my Playground page, I initialize the editor like this, (setting the "startval" parameter if I got data):
var opt = 'schema:' + schema + (startval.trim() ? ', startval:' + startval : '');
return 'var jseditor = new window.JSONEditor(document.querySelector("#json-editor-form"),{' + opt + '});';
The startval feature already exists in the json-editor/json-editor. But is not being leveraged in the dmstr/yii2-json-editor/src/JsonEditorWidget.php script.
@germanbisurgi My mistake. I totally overlooked that this was a different repo. 😁
I would like to propose to use the "startval" option during the initialization of the JSON Editor instead of setting the value after the instance creation.
Current: new JSONEditor -> ready (no data yet) -> setValue () Proposition: new JSONEditor(startval) -> ready (data already loaded)
This is useful for editors that implements plugins like selectize.js because they need an input that already has a value. Listening to the ready event insures that.