jeudi 27 février 2020

Confirm Checkbox Via Alert

I am trying to make a checkbox become checked/Not checked after a user confirms via a model.

The user would click a checkbox, then be prompted by an alert that says "Accept" to check the box or "Cancel" to uncheck or not allow the checkbox to check.

I am using the Package React Confirm Alert with Informed for my forms.

I have created a Sandbox here https://codesandbox.io/s/hardcore-sara-j34x8

My code is below.

 const Bear = () => {
    confirmAlert({
      title: "Confirm to submit",
      message: "Are you sure to do this.",
      willUnmount: () => {},
      buttons: [
        {
          label: "Yes",
          onClick: e => {
            //console.log("True");
            // return true;
          }
        },
        {
          label: "No",
          onClick: e => {
            console.log("false");
            return false;
          }
        }
      ]
    });
  };
eturn (
    <div className="App">
      <label className="saAdminCheckBoxLabel">
        <Checkbox
          onClick={e => {
            Bear();
          }}
          field="arecNeutral"
        />
        <span>Neutral USE THIS ONE</span>
      </label>
    </div>
  );
}



Aucun commentaire:

Enregistrer un commentaire