Skip to content

Commit

Permalink
Applied button selector fix when used with Pjax (see #8).
Browse files Browse the repository at this point in the history
  • Loading branch information
drsdre committed Nov 29, 2016
1 parent c74af21 commit 02546ec
Showing 1 changed file with 42 additions and 8 deletions.
50 changes: 42 additions & 8 deletions js/wizardwidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,66 @@ $(document).ready(function () {

//Wizard
$('a[data-toggle="tab"]').on('show.bs.tab', function (e) {

var $target = $(e.target);

if ($target.parent().hasClass('disabled')) {
return false;
}
});

$(".next-step").click(function (e) {
// Manage next step button click
$(document).on("click", ".next-step", function (e) {
var $tab_active = $('.wizard .nav-tabs li.active');
var $next_tab = $active.next();
var $function = jQuery(this).data('function') || false;

var $active = $('.wizard .nav-tabs li.active');
$active.next().removeClass('disabled');
nextTab($active);
if ($function){
var callback = function(){
$next_tab.removeClass('disabled');
nextTab($tab_active);
};

// Execute data item 'function' on click
eval($function);
} else {
$next_tab.removeClass('disabled');
nextTab($tab_active);
}
});
$(".prev-step").click(function (e) {

var $active = $('.wizard .nav-tabs li.active');
prevTab($active);
// Manage previous step button click
$(document).on("click", ".prev-step", function (e) {
var $tab_active = $('.wizard .nav-tabs li.active');
var $function = jQuery(this).data('function') || false;

if ($function){
var callback = function(){
prevTab($tab_active);
};

// Execute data item 'function' on click
eval($function);
} else {
prevTab($tab_active);
}
});

// Manage save step button click
$(document).on("click", ".save-step", function (e) {
var $function = jQuery(this).data('function') || false;
// Execute data item 'function' on click
if ($function){
eval($function);
}
});
});

// 'click' on next tab
function nextTab(elem) {
$(elem).next().find('a[data-toggle="tab"]').click();
}

// 'click' on prev tab
function prevTab(elem) {
$(elem).prev().find('a[data-toggle="tab"]').click();
}

1 comment on commit 02546ec

@sebastianmenendez
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 17:

var $next_tab = $active.next();

Should be:

var $next_tab = $tab_active.next();

Please sign in to comment.