Closed rhythmicdevil closed 8 years ago
@rhythmicdevil file2 will create a new instance. currently events must be declared at instance initiation.
You can do however something like this:
$(document).ready(function() {
$('#rootwizard').bootstrapWizard({
onTabShow: function(tab, navigation, index) {
var total = navigation.find('li').length;
var current = index+1;
var percent = (current/total) * 100;
$('#rootwizard').find('.progress-bar').css({width:percent+'%'});
// If it's the last tab then hide the last button and show the finish instead
if(current >= total) {
$('#rootwizard').find('.pager .next').hide();
$('#rootwizard').find('.pager .finish').show();
$('#rootwizard').find('.pager .finish').removeClass('disabled');
/*
* Hide the link to the advanced view when not on the first page.
*/
$("a[href='advanced']").parent().hide();
}
else if (current == 1){
$('#rootwizard').find('.pager .previous').hide();
$('#rootwizard').find('.pager .cancel').show().removeClass('disabled');
/*
* Show the link to the advanced view when on the first page.
*/
$("a[href='advanced']").parent().show();
}
else {
$('#rootwizard').find('.pager .previous').show();
$('#rootwizard').find('.pager .cancel').hide().addClass('disabled');
$('#rootwizard').find('.pager .next').show();
$('#rootwizard').find('.pager .finish').hide().addClass('disabled');
/*
* Hide the link to the advanced view when not on the first page.
*/
$("a[href='advanced']").parent().hide();
}
},
'onNext': function (tab, navigation, index){
if(typeof onNextCallback == 'function') {
onNextCallback();
}
}
});
});
file 2
function onNextCallback() {
....
}
You get the idea.
I have a case where I have two JS files. The first creates the instance. The second is only loaded on some views and in it I want to add an option to the wizard. I cant seem to get it to work.
File 1:
File 2: