Sweetalert2 javascript (progresStep) - PullRequest
       7

Sweetalert2 javascript (progresStep)

0 голосов
/ 02 ноября 2018

Итак, у меня возникли проблемы с sweetalert2 (я новичок здесь).

У меня есть этот скрипт, и я не знаю, как сделать, чтобы быть с шагом прогресса (см. .Gif ниже)

<a href="javascript:void(0)" onclick="givepptoplayer()">Set Premium Points</a></li>

<script>
  function givepptoplayer() {
    swal({
       title: 'Change User Premium Points <?php echo $data->name ?>',
       input: 'number',
       showCancelButton: false,
       confirmButtonText: 'edit',
       showLoaderOnConfirm: true,
       confirmButtonClass: 'btn btn-success',
       cancelButtonClass: 'btn btn-danger m-l-10',
       allowOutsideClick: false,
       inputValue: '',
     }).then(function (result) {           
       $.post('<?php echo config::$_PAGE_URL ?>api/finishthis', { 'userid' : '<?php echo $data->id ?>', 'changePP': result.value}, function(result) 
         { 
           swal({
             type: 'success',
             title: 'Succes!',
             html: result
           });
         });
     });                                    
   }
</script>

Я хочу, чтобы добиться прогресса. Шаг примерно такой: https://gyazo.com/41f65065108e3937e3afc2a3064ee028

Не могли бы вы дать мне пример, пожалуйста?

1 Ответ

0 голосов
/ 03 ноября 2018

Существует пример объединения модалов со связанным кодом на https://sweetalert2.github.io/#chaining-modals. В основном код:

swal.mixin({
  input: 'text',
  confirmButtonText: 'Next &rarr;',
  showCancelButton: true,
  progressSteps: ['1', '2', '3']
}).queue([
  {
    title: 'Question 1',
    text: 'Chaining swal2 modals is easy'
  },
  'Question 2',
  'Question 3'
]).then((result) => {
  if (result.value) {
    swal({
      title: 'All done!',
      html:
        'Your answers: <pre><code>' +
          JSON.stringify(result.value) +
        '
», verifyButtonText: «Прекрасно!» }) } })
...