iziToast icon indicating copy to clipboard operation
iziToast copied to clipboard

On Ajax send, change an option of current instance

Open AbiruzzamanMolla opened this issue 8 months ago • 0 comments

i am sending request via ajax. i would like to stop the closing timer when i click yes.

` $('#translateAll').click(function() { iziToast.question({ timeout: 20000, close: false, overlay: true, displayMode: 'once', id: 'question', zindex: 999, title: 'Hey', message: 'This will take a while, are you sure?', position: 'center', buttons: [ ['', function(instance, toast) { var isDemo = "{{ env('PROJECT_MODE') }}"; var code = $('#translateAll').data('code'); var file = $('#translateAll').data('file');

                    if (isDemo == 0) {
                        toastr.error('This Is Demo Version. You Can Not Change Anything');
                        instance.hide({
                            transitionOut: 'fadeOut'
                        }, toast, 'button');
                        return;
                    }

                    $.ajax({
                        type: "post",
                        data: {
                            _token: '{{ csrf_token() }}',
                            code: code,
                            file: file,
                        },
                        url: "{{ route('admin.translateAll') }}",
                        beforeSend: function() {
                            toastr.success('starting');
                        },
                        success: function(response) {
                            if (response.success) {
                                instance.hide({
                                     transitionOut: 'fadeOut'
                                 }, toast, 'button');
                                 toastr.success(response.message);
                                 setTimeout(function() {
                                     window.location.reload();
                                 }, 2000);
                            }
                        },
                        error: function(err) {
                            toastr.error('Failed!')
                            console.log(err);
                            instance.hide({
                                transitionOut: 'fadeOut'
                            }, toast, 'button');
                        },
                    })

                }, true],
                ['<button>NO</button>', function(instance, toast) {

                    instance.hide({
                        transitionOut: 'fadeOut'
                    }, toast, 'button');

                }],
            ],
            onClosing: function(instance, toast, closedBy) {},
            onClosed: function(instance, toast, closedBy) {}
        });
    });`

inside beforeSend: function() { toastr.success('starting'); }, i want to do someting like instance.timeout: false

how can i do this?

AbiruzzamanMolla avatar Oct 25 '23 13:10 AbiruzzamanMolla