Skip to content

Returning value of button click in Modal #207

Answered by markacianfrani
rbureau85 asked this question in Q&A
Discussion options

You must be logged in to vote

You should be able to listen in on the ruxmodalclosed event, which will return false if the user canceled or true if they accepted.

Something like:

   <RuxModal
        open
        onRuxmodalclosed={(e) => {
          // e.detail contains the data returned by the custom event
          if (e.detail) {
            console.log("User confirmed!");
          } else {
            console.log("User canceled");
          }
        }}
      />

https://codesandbox.io/s/condescending-breeze-7c2dy?file=/src/App.js

Does that work for you?

We're also reworking Modal in 7.0 to use slots to give you more control over each piece of the Modal, but unfortunately that'll require a breaking change so we ca…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rbureau85
Comment options

Answer selected by rbureau85
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants