[Vuejs]-Utlizing Promise To control Event Flow in VueJs

2👍

SweetAlert confirm windows use a callback function, not a promise. Then within that callback you’d use promises like

onRequestSubmit: function (e) {
    e.preventDefault();

    swal({
            title: "Are you sure?",  
            showCancelButton: true,   
            confirmButtonText: "Yes"
        }, 
        this.onRequestConfirm.bind(this)
    );
},
onRequestConfirm: function() {
    this.vm.$http[this.getRequestType()](this.el.getAttribute("data-delete-url"), this.aggregateData())
    .then(this.onComplete.bind(this))
    .catch(this.onError.bind(this));
}

edit: removed this.fireFlashMessage() as no longer using that func, although you could refactor it out again if you want

👤Jeff

Leave a comment