I have added a Bootstrap Wizard
inside the modal, and I need to initialize the Wizard
only when this actually exists on the DOM
'cause I have to calculate the width
, when the modal is closed if I execute:
$('.card-wizard').width()
I get: 0
, when the modal is opened if I execute the same command above I get 465. The problem is that I have to calculate the width
after that the modal is opened otherwise the width()
method will return 0.
What I tried so far is:
$('a[href="#account"]').on('shown.bs.tab', function(){
$('.card-wizard').bootstrapWizard({
onInit: function(tab, navigation, index){
let width = $('.card-wizard').width();
}
});
});
the tab is defined in that way:
<div class="wizard-navigation">
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active" href="#account" data-toggle="tab" role="tab">
Account
</a>
</li>
and the wizard is contained inside the member-modal
which is opened using $('#member-modal').modal('show');
is there a way to initialize the BootStrap Wizard
after the modal show?
The width is 0 because your element is inside the modal that is hidden.
You can workaround using .show( complete ).
The snippet: