Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reopening modal when modal already active #21687

Closed
projct1 opened this issue Jan 12, 2017 · 6 comments
Closed

Fix reopening modal when modal already active #21687

projct1 opened this issue Jan 12, 2017 · 6 comments
Labels

Comments

@projct1
Copy link

projct1 commented Jan 12, 2017

I need open new modal from current modal by click button inside current modal.

Now i can do this only with crutch:

/* onening new modal when modal already active */
setTimeout(function() {
    $('#modal').modal();
}, 1000);

Otherwise i have error Uncaught Error: Modal is transitioning

Example here https://jsfiddle.net/rorc/nke1dvpz/

@ghiscoding
Copy link

I think this is a duplicate of #21607 which has a fix coming.

@pvdlg
Copy link
Contributor

pvdlg commented Jan 14, 2017

Instead of setting a timeout you should listen for the event hidden.bs.modal on your first modal.
That would indicate the first modal is closed and then you can open the second one.

Something like that:

$('#firstModal').one('hidden.bs.modal', function () {
    $('#secondModal').modal('show');
});

@projct1
Copy link
Author

projct1 commented Jan 15, 2017

@vanduynslagerp Yea, but in my case code will big and dirty:

let editSelection = function(e) {
    const open = function() {
        $modal.modal({
            keyboard: false,
            backdrop: 'static'
        });
    };

    $modal.one('hidden.bs.modal', open);

    swal('Attention!', 'Save before open new modal?', 'warning').then(() => {
        $.post('/save', function() {
            $modal.modal('hide');
        }).catch(function() {
            $modal.off('hidden.bs.modal', open);
        });
    }, () => $modal.modal('hide'));
}

@pvdlg
Copy link
Contributor

pvdlg commented Jan 15, 2017

It doesn't seem particularly big or ugly.
That's how asynchronous calls are handled. Here is an example in Bootstrap modal unit tests.

I'm not exactly sure what you are trying to achieve here, but I gather that it would be something like that:

  1. Open modal 1
  2. User action
  3. Server call
  4. Close Modal 1
  5. Display Modal 2

Maybe, after the post, instead of closing modal 1 and opening Modal2, you could stay in Modal 1 and change it's content ? Like that:

  1. Open modal 1
  2. User action
  3. Server call
  4. Refresh modal 1 content

@projct1
Copy link
Author

projct1 commented Jan 15, 2017

Its good, but i need return previous content of modal 1 and probably in future i need to 3'th modal...
Ok dude, thanks for reply, lets forget this 😃
Sigh, but i would be happy if bootstrap will starts support multiple modals native like this http://jsfiddle.net/CxdUQ/
Just amazing 😄

@Johann-S
Copy link
Member

Johann-S commented May 3, 2017

Close due to the merge of #21743 , fix will be available at our next release

@Johann-S Johann-S closed this as completed May 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants