jsonform icon indicating copy to clipboard operation
jsonform copied to clipboard

onSubmit-function not executed in the playground

Open Gitward opened this issue 9 years ago • 4 comments

I tried the following code in the playground (http://ulion.github.io/jsonform/playground/)

{
        "schema": {
          "name": {
            "type": "string",
            "title": "Name",
            "required": true
          }
        },
        "form": [
          "name"
        ],
        "onSubmit": function (errors, values) {
          if (errors) {
            alert("Errors" + JSON.stringify(errors, null, '  '));
          }
          else {
            alert("No errors");
          }
      }
}

Running this code in an own HTML-file works with alerting an error-Message:

[
  {
    "uri": "urn:uuid:b36484d3-317d-4848-8511-512df317c225#/required",
    "schemaUri": "http://json-schema.org/draft-03/hyper-schema#/properties/required",
    "attribute": "type",
    "message": "Instance is not a required type",
    "details": [
      "boolean"
    ]
  }
]

Running it within the playground shows an error for the onSubmit-part. Besides that, the onSubmit-code is not executed.

Gitward avatar Apr 28 '15 08:04 Gitward

tried it in playground, no error found.

2015-04-28 16:42 GMT+08:00 Gitward [email protected]:

I tried the following code in the playground ( http://ulion.github.io/jsonform/playground/)

{ "schema": { "name": { "type": "string", "title": "Name", "required": true } }, "form": [ "name" ], "onSubmit": function (errors, values) { if (errors) { alert("Errors" + JSON.stringify(errors, null, ' ')); } else { alert("No errors"); } } }

Running this code in an own HTML-file works with alerting an error-Message:

[ { "uri": "urn:uuid:b36484d3-317d-4848-8511-512df317c225#/required", "schemaUri": "http://json-schema.org/draft-03/hyper-schema#/properties/required", "attribute": "type", "message": "Instance is not a required type", "details": [ "boolean" ] } ]

Running it within the playground shows an error for the onSubmit-part. Besides that, the onSubmit-code is not executed.

— Reply to this email directly or view it on GitHub https://github.com/ulion/jsonform/issues/9.

Ulion

ulion avatar Apr 28 '15 11:04 ulion

I don't get the alert window as define in the onSubmit. The only alert I get is: alert

And here is the error I get: error2

Don't you see that error? Do you get the alert-window defined in the onSubmit?

Gitward avatar Apr 28 '15 12:04 Gitward

no, I don't get it, but the error is just the editor alert it's not a valid JSON.

the reason which is not called maybe related it's in playground, in real code, it will be called. so you are saying the playground has bug which cause the onSubmit defined in the editor was not called?

2015-04-28 20:11 GMT+08:00 Gitward [email protected]:

I don't get the alert window as define in the onSubmit. The only alert I get is: [image: alert] https://cloud.githubusercontent.com/assets/8510849/7369161/b20bdb92-edaf-11e4-901b-32128a303a76.png

And here is the error I get: [image: error2] https://cloud.githubusercontent.com/assets/8510849/7369207/4d8bab88-edb0-11e4-9e17-2245d0cc4a51.png

Don't you see that error? Do you get the alert-window defined in the onSubmit?

— Reply to this email directly or view it on GitHub https://github.com/ulion/jsonform/issues/9#issuecomment-97038975.

Ulion

ulion avatar Apr 28 '15 12:04 ulion

so you are saying the playground has bug which cause the onSubmit defined in the editor was not called?

Yes. But when you say this is intentional, than I'll close this ticket.

Gitward avatar Apr 28 '15 13:04 Gitward