swal fire on click back and forth forward

Solutions on MaxInterview for swal fire on click back and forth forward by the best coders in the world

showing results for - "swal fire on click back and forth forward"
Laura
12 Jun 2016
1const steps = ['1', '2', '3']
2const swalQueueStep = Swal.mixin({
3    confirmButtonText: 'Forward',
4    cancelButtonText: 'Back',
5    progressSteps: steps,
6    input: 'text',
7    inputAttributes: {
8        required: true
9    },
10    reverseButtons: true,
11    validationMessage: 'This field is required'
12})
13async function backAndForth() {
14    const values = []
15    let currentStep
16    for (currentStep = 0; currentStep < steps.length;) {
17        if (steps[currentStep] == 1) {
18            var result = await swalQueueStep.fire({
19                title: 'Question .' + steps[currentStep],
20                inputValue: values[currentStep],
21                showCancelButton: currentStep > 0,
22                currentProgressStep: currentStep
23            })
24        } else if (steps[currentStep] == 2) {
25            var result = await swalQueueStep.fire({
26                title: 'Question ..' + steps[currentStep],
27                inputValue: values[currentStep],
28                showCancelButton: currentStep > 0,
29                currentProgressStep: currentStep
30            })
31        } else if (steps[currentStep] == 3) {
32            var result = await swalQueueStep.fire({
33                title: 'Question ...' + steps[currentStep],
34                inputValue: values[currentStep],
35                showCancelButton: currentStep > 0,
36                currentProgressStep: currentStep
37            })
38        } else {
39            break
40        }
41        if (result.value) {
42            values[currentStep] = result.value
43            currentStep++
44        } else if (result.dismiss === 'cancel') {
45            currentStep--
46        } else {
47            break
48        }
49
50        if (currentStep === steps.length) {
51            Swal.fire(JSON.stringify(values))
52        }
53    }
54}
55backAndForth();
56