mercredi 27 mars 2019

Sweet alert 2 multiple checkbox

I'm using this "sweet alert 2", I I need of multiple checkbox, In documentation there is 'input-radio' option with multiple choice, but only single choice for checkbox option.

Is there possibily to use this script with checkbox multiple choice?

https://sweetalert2.github.io/#input-radio

https://sweetalert2.github.io/#input-checkbox

// inputOptions can be an object or Promise
const inputOptions = new Promise((resolve) => {
  setTimeout(() => {
    resolve({
      '#ff0000': 'Red',
      '#00ff00': 'Green',
      '#0000ff': 'Blue'
    })
  }, 1000)
})

const {value: color} = await Swal.fire({
  title: 'Select color',
  input: 'radio',
  inputOptions: inputOptions,
  inputValidator: (value) => {
    if (!value) {
      return 'You need to choose something!'
    }
  }
})

if (color) {
  Swal.fire({html: 'You selected: ' + color}

single checkbox

const {value: accept} = await Swal.fire({
  title: 'Terms and conditions',
  input: 'checkbox',
  inputValue: 1,
  inputPlaceholder:
    'I agree with the terms and conditions',
  confirmButtonText:
    'Continue <i class="fa fa-arrow-right></i>',
  inputValidator: (result) => {
    return !result && 'You need to agree with T&C'
  }
})

if (accept) {
  Swal.fire('You agreed with T&C :)')
}

thanks




Aucun commentaire:

Enregistrer un commentaire