Skip to content

Validation currently depends on 'ready' event regardless of 'ajax' setting #124

@brettz9

Description

@brettz9

The README says:

*Note If the ajax property is true and JSON Editor needs to fetch an external url, the api methods won't be available immediately.
Listen for the ready event before calling them.

editor.on('ready',function() {
  // Now the api methods will be available
  editor.validate();
});

However, at least in Firefox, this pattern is also required regardless of whether ajax is true.

(This is because requestAnimationFrame acts asynchronously to set self.validation_results and validation_results will not yet have been set if editor.validate() is called immediately after the editor instantiation.)

I didn't know if you wanted the README to clarify this or if you want to avoid the asynchronicity for non-Ajax JSON validation.

Also, as an aside (and I'll start a new issue for it if you are open to it), it would be awesome if we could optionally support $ref JSON references within normal JSON files in addition to use within JSON Schema: http://tools.ietf.org/id/draft-pbryan-zyp-json-ref-03.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions