0

what is the event for swal close by another swal. Means if a swal is already present, in the mean time another swal is fired, I want to know the dismissal event of closed swal. what is the procedure for this?

I've tried these

var share = {
        showConfirmButton: false,
        html: `<div class="card">
                <div class="card-header card-header-icon" data-background-color="rose">
                    <i class="material-icons">screen_share</i>
                </div>
                <div class="card-content">
                    <h4 class="card-title">Shared screen</h4>
                    <div id="view-share">
                        <div id="test`+ streamId +`"></div>
                    </div>
                </div>
            </div>`,
        onOpen: () => {
            console.log('showing share', streamId);
            shareStream.show('test' + streamId, 'Shared');
            Shared.openShare.set('stream', shareStream);
        },
        onClose:() => {
            console.log('share window closed');
        },
        allowOutsideClick: false,
        background: 'transparent',
        showCloseButton: true,
        width: '800px',
        // grow: 'fullscreen'
    };


    swal(share).then(() => { }, (dismiss) => {

        console.log(dismiss);
        // if (dismiss == 'cancel') {
        this.minimize(shareStream);
        Shared.openShare.clear();
        // }
    });

Chaining modals won't work for me. Scenario is I've rendering remote screen shares in swal modal. Sometimes it might happen that another screen share can come to me. When that new share comes, I want to minimize the share to a pane for minimization and open a swal for the new one. Otherwise previous shares will be lost as swal does not fire any event before closing already shown swal.

code from swal2 library

var init = function init(params) {
  // Clean up the old modal if it exists
  var c = getContainer();
  if (c) {
    c.parentNode.removeChild(c);
  }

I've already implemented it by storing the shown stream information in a variable. whenever showShare method is called, I'm checking if there is any information stored in that variable. If it is there, minimisation code is called, then new swal is displayed.

if (Shared.openShare.size>0) {
            this.minimize(Shared.openShare.get('stream'));
        }

But if there is any neat and clean way, it would be better.

Bobby
  • 141
  • 11
  • Possible duplicate of [How to listen for when sweet alert closes](https://stackoverflow.com/questions/46639492/how-to-listen-for-when-sweet-alert-closes) – Hayden Passmore Nov 13 '17 at 22:43
  • @HaydenPassmore, you didn't get my question. If my swal is visible, and another swal has been fired, there is no close event being fired as per the sweetalert library v6.4.2. how to check this. – Bobby Nov 15 '17 at 12:09
  • Do you have any example code of what you have tried? I think you are able to achieve this using chaining modals with queues. – Hayden Passmore Nov 15 '17 at 23:12
  • I've tried putting the logs in both `onClose` and `dismiss` callbacks. I've edited my question with code – Bobby Nov 16 '17 at 04:04

0 Answers0