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/
I think this is a duplicate of #21607 which has a fix coming.
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');
});
@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'));
}
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:
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:
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 馃槃
Close due to the merge of #21743 , fix will be available at our next release
Most helpful comment
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 馃槃