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

feat: submit button callback #1499

Merged
merged 3 commits into from
Jan 28, 2025
Merged

Conversation

silvester-pari
Copy link
Collaborator

@silvester-pari silvester-pari commented Jan 27, 2025

Implemented changes

This PR adds a default callback for an onSubmit function, which just emits the submit event on the eox-jsonform element.

Background

json-editor supports defining a button on the form, which only is clickable once validation passes, e.g.:

button: {
  format: "button",
  options: {
    button: {
      text: "Submit",
      action: "onSubmit",
      validated: true,
    },
  },
},

In order to do something on click, an onSubmit callback must be registered before initializing the JSONEditor. In order to support a generic "submit" functionality, a onSubmit callback was registered, which dispatches a custom submit event, so that it can be listened e.g.:

<eox-jsonform
  @submit=${(e) => alert(`Submitted: ${JSON.stringify(e.detail)}`)}
></eox-jsonform>

Screenshots/Videos

Checklist before requesting a review

Copy link

netlify bot commented Jan 27, 2025

Deploy Preview for eoxelements ready!

Name Link
🔨 Latest commit e82b750
🔍 Latest deploy log https://app.netlify.com/sites/eoxelements/deploys/6797a439a4e5380008b44506
😎 Deploy Preview https://deploy-preview-1499--eoxelements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@silvester-pari silvester-pari changed the title Jsonform/feat/submit button callback feat: submit button callback Jan 27, 2025
@silvester-pari silvester-pari marked this pull request as ready for review January 27, 2025 15:26
@silvester-pari silvester-pari merged commit b48d381 into main Jan 28, 2025
7 checks passed
@silvester-pari silvester-pari deleted the jsonform/feat/submit-button-callback branch January 28, 2025 08:34
@github-actions github-actions bot mentioned this pull request Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants