skip to Main Content

I have a form with Twitter Bootstrap Wizard and I have several images that when I select one, I must store locally the value and go to the next tab (o._nextTab).

When I click the image it should go to the next tab, but currently is not working.

This is the idea:

(function($) {
"use strict";
var sdm = function() {
    var o = this; 
    $(document).ready(function() {
        o.initialize();
    });
};
var p = sdm.prototype;
p.initialize = function() {
  this._initChartWizard();
};


//Chart Wizard form
p._initChartWizard = function () {
  var o = this;
  $('#chartwizard').bootstrapWizard({
    onTabShow: function (tab, navigation, index) {
      o._handleTabShow(tab, navigation, index, $('#chartwizard'));
      o._nextTab(o);
    }
  });

  $('#chartwizard').bootstrapWizard({ 'nextSelector': '.chartOption' });

}

p._handleTabShow = function (tab, navigation, index, wizard) {
  var total = navigation.find('li').length;
  var current = index + 0;
  var percent = (current / (total - 1)) * 100;
  var percentWidth = 100 - (100 / total) + '%';

  navigation.find('li').removeClass('done');
  navigation.find('li.active').prevAll().addClass('done');

  wizard.find('.progress-bar').css({ width: percent + '%' });
  $('.form-wizard-horizontal').find('.progress').css({ 'width': percentWidth });
}

p._nextTab = function(wizard) {
  $('.nextT').click(function(){
    wizard('next');
  });
}

window.boostbox = window.boostbox || {};
window.boostbox.sdm = new sdm;
}(jQuery)); // pass in (jQuery):

There will be several images, I want to click on the image and go to the next tab, or at least select the image and then when I click next get the value.

I’m using pyjade to create the templates so if theres any idea there or using javascript it will be welcome.

<div id="chartwizard" class="form-wizard form-wizard-horizontal">
<form role="form" novalidate="novalidate" class="form-horizontal form-bordered">
  <div class="form-wizard-nav">
    <div class="progress">
      <div class="progress-bar progress-bar-primary"></div>
    </div>
    <ul class="nav nav-justified">
      <li class="active"><a href="#tab1" data-toggle="tab"><span class="step">1</span><span class="title">Chart Type</span></a>
      </li>
      <li><a href="#tab2" data-toggle="tab"><span class="step">2</span><span class="title">Data Source</span></a>
      </li>
      <li><a href="#tab3" data-toggle="tab"><span class="step">3</span><span class="title">Data</span></a>
      </li>
      <li><a href="#tab4" data-toggle="tab"><span class="step">4</span><span class="title">Chart Options</span></a>
      </li>
    </ul>
  </div>
  <div class="tab-content">
    <div id="tab1" class="tab-pane active">
      <div class="row">
        <div class="col-sm-3">
          <div class="box">
            <div class="box-body chartOption nexT"><a href="javascript:void(0);"><img src="static/assets/img/business-bars-graphic.png" class="img-responsive"/></a>
            </div>
          </div>
        </div>
        <div class="col-sm-3">
          <div class="box">
            <div class="box-body"><a href="javascript:void(0);"><img src="static/assets/img/business-chart.png" class="img-responsive"/></a>
            </div>
          </div>
        </div>
        <div class="col-sm-3">
          <div class="box">
            <div class="box-body"><a href="javascript:void(0);"><img src="static/assets/img/business-financial-chart (1).png" class="img-responsive"/></a>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div id="tab2" class="tab-pane"><br/><br/>
      <p>Tab 2</p>
    </div>
    <div id="tab3" class="tab-pane"><br/><br/>
      <p>Tab 3</p>
    </div>
    <div id="tab4" class="tab-pane"><br/><br/>
      <p>Tab 4</p>
    </div>
  </div>
  <div class="pager wizard">
    <li class="previous first"><a href="javascript:void(0);">First</a>
    </li>
    <li class="previous"><a href="javascript:void(0);">Previous</a>
    </li>
    <li class="next last"><a href="javascript:void(0);">Last</a>
    </li>
    <li class="next"><a href="javascript:void(0);">Next</a>
    </li>
  </div>
</form>
</div>

4

Answers


  1. There are two problems in your code.

    1. The class name nexT in <div class="box-body chartOption nexT"> should be nextT as you write this in your js: $('.nextT').click(function(){
    2. The wizard is not a function, so you can’t call it like wizard('next');. You can take advantage of its nextSelector(recommended) or write $(".next:not(.last)").click(); instead.

    After fixing these problems, your code should be like this:

    <body>
        <div id="chartwizard" class="form-wizard form-wizard-horizontal">
            <form role="form" novalidate="novalidate" class="form-horizontal form-bordered">
                <div class="form-wizard-nav">
                    <div class="progress">
                        <div class="progress-bar progress-bar-primary"></div>
                    </div>
                    <ul class="nav nav-justified">
                        <li class="active"><a href="#tab1" data-toggle="tab"><span class="step">1</span><span class="title">Chart Type</span></a>
                        </li>
                        <li><a href="#tab2" data-toggle="tab"><span class="step">2</span><span class="title">Data Source</span></a>
                        </li>
                        <li><a href="#tab3" data-toggle="tab"><span class="step">3</span><span class="title">Data</span></a>
                        </li>
                        <li><a href="#tab4" data-toggle="tab"><span class="step">4</span><span class="title">Chart Options</span></a>
                        </li>
                    </ul>
                </div>
                <div class="tab-content">
                    <div id="tab1" class="tab-pane active">
                        <div class="row">
                            <div class="col-sm-3">
                                <div class="box">
                                    <div class="box-body chartOption nexTT">
                                        <a href="javascript:void(0);"><img src="img/head.png" class="img-responsive" /></a>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-3">
                                <div class="box">
                                    <div class="box-body">
                                        <a href="javascript:void(0);"><img src="img/head.png" class="img-responsive" /></a>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-3">
                                <div class="box">
                                    <div class="box-body">
                                        <a href="javascript:void(0);"><img src="img/head.png" class="img-responsive" /></a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div id="tab2" class="tab-pane"><br/><br/>
                        <p>Tab 2</p>
                    </div>
                    <div id="tab3" class="tab-pane"><br/><br/>
                        <p>Tab 3</p>
                    </div>
                    <div id="tab4" class="tab-pane"><br/><br/>
                        <p>Tab 4</p>
                    </div>
                </div>
                <div class="pager wizard">
                    <li class="previous first"><a href="javascript:void(0);">First</a>
                    </li>
                    <li class="previous"><a href="javascript:void(0);">Previous</a>
                    </li>
                    <li class="next last"><a href="javascript:void(0);">Last</a>
                    </li>
                    <li class="next"><a href="javascript:void(0);">Next</a>
                    </li>
                </div>
            </form>
        </div>
        <script>
            (function ($) {
                "use strict";
                var sdm = function () {
                    var o = this;
                    $(document).ready(function () {
                        o.initialize();
                    });
                };
                var p = sdm.prototype;
                p.initialize = function () {
                    this._initChartWizard();
                };
    
    
                //Chart Wizard form
                p._initChartWizard = function () {
                    var o = this;
                    $('#chartwizard').bootstrapWizard({
                        onTabShow: function (tab, navigation, index) {
                            o._handleTabShow(tab, navigation, index, $('#chartwizard'));
                            console.log(this);
                            o._nextTab(o);
                        }
                    });
    
                    $('#chartwizard').bootstrapWizard({
                        'nextSelector': '.chartOption'
                    });
    
                }
    
                p._handleTabShow = function (tab, navigation, index, wizard) {
                    var total = navigation.find('li').length;
                    var current = index + 0;
                    var percent = (current / (total - 1)) * 100;
                    var percentWidth = 100 - (100 / total) + '%';
    
                    navigation.find('li').removeClass('done');
                    navigation.find('li.active').prevAll().addClass('done');
    
                    wizard.find('.progress-bar').css({
                        width: percent + '%'
                    });
                    $('.form-wizard-horizontal').find('.progress').css({
                        'width': percentWidth
                    });
                }
    
                p._nextTab = function (wizard) {
                    $('.nexTT').click(function () {
                        $(".next:not(.last)").click();
                    });
                }
    
                window.boostbox = window.boostbox || {};
                window.boostbox.sdm = new sdm;
            }(jQuery)); // pass in (jQuery):
        </script>
    </body>

    Refer to http://vinceg.github.io/twitter-bootstrap-wizard/

    Login or Signup to reply.
  2. The following will save the selections made (and advance to the next tab). Selections are stored in an object by tab index.

    It saves the element ID of elements that have the class saveAndMoveNext. This class is also what triggers the “save this and move to the next tab”.

    When running it is best to click on the “Full Page” link. I’m not familiar with pyjade, but I have tried to keep it as close to how it was written in the question:

    // shim to execute code as written
    var p = {};
    
    var chosenSelections = {}; // stores each selection by tab #
    
    //Chart Wizard form
    p._initChartWizard = function() {
      var o = this;
      var $chartwizard = $('#chartwizard'); // cache
    
      $chartwizard.bootstrapWizard({
        onTabShow: function(tab, navigation, index) {
          o._handleTabShow(tab, navigation, index, $chartwizard);
        }
      });
    
      // set up selection saving and moving to next tab
      $('#chartwizard').find(".saveAndMoveNext").click(function() {
        o._saveAndChangeTab($chartwizard, this)
      });
    
    }
    
    p._handleTabShow = function(tab, navigation, index, wizard) {
      var total = navigation.find('li').length;
      var current = index + 0;
      var percent = (current / (total - 1)) * 100;
      var percentWidth = 100 - (100 / total) + '%';
    
      navigation.find('li').removeClass('done');
      navigation.find('li.active').prevAll().addClass('done');
    
      wizard.find('.progress-bar').css({
        width: percent + '%'
      });
      $('.form-wizard-horizontal').find('.progress').css({
        'width': percentWidth
      });
    }
    
    p._saveAndChangeTab = function(wizard, el) {
      var currentTab = wizard.bootstrapWizard('currentIndex');
    
      chosenSelections[currentTab] = el.id;
      
      console.log("Selection saved by tab index:",chosenSelections);
      
      wizard.bootstrapWizard('next'); // move to next tab
    }
    
    //window.boostbox = window.boostbox || {};
    //window.boostbox.sdm = new sdm;
    //}(jQuery)); // pass in (jQuery):
    
    // A shim to execute code as written
    $(document).ready(function() {
      p._initChartWizard();
    });
    <script src="https://code.jquery.com/jquery-latest.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="https://vinceg.github.io/twitter-bootstrap-wizard/jquery.bootstrap.wizard.js"></script>
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    
    <div id="chartwizard" class="form-wizard form-wizard-horizontal">
      <form role="form" novalidate="novalidate" class="form-horizontal form-bordered">
        <div class="form-wizard-nav">
          <div class="progress">
            <div class="progress-bar progress-bar-primary"></div>
          </div>
          <ul class="nav nav-justified">
            <li class="active"><a href="#tab1" data-toggle="tab"><span class="step">1</span><span class="title">Chart Type</span></a>
            </li>
            <li><a href="#tab2" data-toggle="tab"><span class="step">2</span><span class="title">Data Source</span></a>
            </li>
            <li><a href="#tab3" data-toggle="tab"><span class="step">3</span><span class="title">Data</span></a>
            </li>
            <li><a href="#tab4" data-toggle="tab"><span class="step">4</span><span class="title">Chart Options</span></a>
            </li>
          </ul>
        </div>
        <div class="tab-content">
          <div id="tab1" class="tab-pane active">
            <div class="row">
              <div class="col-sm-3">
                <div class="box">
                  <div class="box-body">
                    <a href="javascript:void(0);"><img id="image1" class="saveAndMoveNext" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTQwIiBoZWlnaHQ9IjE0MCIgdmlld0JveD0iMCAwIDE0MCAxNDAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjwhLS0KU291cmNlIFVSTDogaG9sZGVyLmpzLzE0MHgxNDAKQ3JlYXRlZCB3aXRoIEhvbGRlci5qcyAyLjYuMC4KTGVhcm4gbW9yZSBhdCBodHRwOi8vaG9sZGVyanMuY29tCihjKSAyMDEyLTIwMTUgSXZhbiBNYWxvcGluc2t5IC0gaHR0cDovL2ltc2t5LmNvCi0tPjxkZWZzPjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+PCFbQ0RBVEFbI2hvbGRlcl8xNWFmZGQyMTE5YSB0ZXh0IHsgZmlsbDojQUFBQUFBO2ZvbnQtd2VpZ2h0OmJvbGQ7Zm9udC1mYW1pbHk6QXJpYWwsIEhlbHZldGljYSwgT3BlbiBTYW5zLCBzYW5zLXNlcmlmLCBtb25vc3BhY2U7Zm9udC1zaXplOjEwcHQgfSBdXT48L3N0eWxlPjwvZGVmcz48ZyBpZD0iaG9sZGVyXzE1YWZkZDIxMTlhIj48cmVjdCB3aWR0aD0iMTQwIiBoZWlnaHQ9IjE0MCIgZmlsbD0iI0VFRUVFRSIvPjxnPjx0ZXh0IHg9IjQzLjUiIHk9Ijc0LjgiPjE0MHgxNDA8L3RleHQ+PC9nPjwvZz48L3N2Zz4="
                        class="img-responsive" /></a>
                  </div>
                </div>
              </div>
              <div class="col-sm-3">
                <div class="box">
                  <div class="box-body">
                    <a href="javascript:void(0);"><img id="image2" class="saveAndMoveNext" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTQwIiBoZWlnaHQ9IjE0MCIgdmlld0JveD0iMCAwIDE0MCAxNDAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjwhLS0KU291cmNlIFVSTDogaG9sZGVyLmpzLzE0MHgxNDAKQ3JlYXRlZCB3aXRoIEhvbGRlci5qcyAyLjYuMC4KTGVhcm4gbW9yZSBhdCBodHRwOi8vaG9sZGVyanMuY29tCihjKSAyMDEyLTIwMTUgSXZhbiBNYWxvcGluc2t5IC0gaHR0cDovL2ltc2t5LmNvCi0tPjxkZWZzPjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+PCFbQ0RBVEFbI2hvbGRlcl8xNWFmZGQyMTE5YSB0ZXh0IHsgZmlsbDojQUFBQUFBO2ZvbnQtd2VpZ2h0OmJvbGQ7Zm9udC1mYW1pbHk6QXJpYWwsIEhlbHZldGljYSwgT3BlbiBTYW5zLCBzYW5zLXNlcmlmLCBtb25vc3BhY2U7Zm9udC1zaXplOjEwcHQgfSBdXT48L3N0eWxlPjwvZGVmcz48ZyBpZD0iaG9sZGVyXzE1YWZkZDIxMTlhIj48cmVjdCB3aWR0aD0iMTQwIiBoZWlnaHQ9IjE0MCIgZmlsbD0iI0VFRUVFRSIvPjxnPjx0ZXh0IHg9IjQzLjUiIHk9Ijc0LjgiPjE0MHgxNDA8L3RleHQ+PC9nPjwvZz48L3N2Zz4="
                        class="img-responsive" /></a>
                  </div>
                </div>
              </div>
              <div class="col-sm-3">
                <div class="box">
                  <div class="box-body">
                    <a href="javascript:void(0);"><img id="image3" class="saveAndMoveNext" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTQwIiBoZWlnaHQ9IjE0MCIgdmlld0JveD0iMCAwIDE0MCAxNDAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjwhLS0KU291cmNlIFVSTDogaG9sZGVyLmpzLzE0MHgxNDAKQ3JlYXRlZCB3aXRoIEhvbGRlci5qcyAyLjYuMC4KTGVhcm4gbW9yZSBhdCBodHRwOi8vaG9sZGVyanMuY29tCihjKSAyMDEyLTIwMTUgSXZhbiBNYWxvcGluc2t5IC0gaHR0cDovL2ltc2t5LmNvCi0tPjxkZWZzPjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+PCFbQ0RBVEFbI2hvbGRlcl8xNWFmZGQyMTE5YSB0ZXh0IHsgZmlsbDojQUFBQUFBO2ZvbnQtd2VpZ2h0OmJvbGQ7Zm9udC1mYW1pbHk6QXJpYWwsIEhlbHZldGljYSwgT3BlbiBTYW5zLCBzYW5zLXNlcmlmLCBtb25vc3BhY2U7Zm9udC1zaXplOjEwcHQgfSBdXT48L3N0eWxlPjwvZGVmcz48ZyBpZD0iaG9sZGVyXzE1YWZkZDIxMTlhIj48cmVjdCB3aWR0aD0iMTQwIiBoZWlnaHQ9IjE0MCIgZmlsbD0iI0VFRUVFRSIvPjxnPjx0ZXh0IHg9IjQzLjUiIHk9Ijc0LjgiPjE0MHgxNDA8L3RleHQ+PC9nPjwvZz48L3N2Zz4="
                        class="img-responsive" /></a>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div id="tab2" class="tab-pane">
            <br/>
            <br/>
            <p>Tab 2</p>
          </div>
          <div id="tab3" class="tab-pane">
            <br/>
            <br/>
            <p>Tab 3</p>
          </div>
          <div id="tab4" class="tab-pane">
            <br/>
            <br/>
            <p>Tab 4</p>
          </div>
        </div>
        <div class="pager wizard">
          <li class="previous first"><a href="javascript:void(0);">First</a>
          </li>
          <li class="previous"><a href="javascript:void(0);">Previous</a>
          </li>
          <li class="next last"><a href="javascript:void(0);">Last</a>
          </li>
          <li class="next"><a href="javascript:void(0);">Next</a>
          </li>
        </div>
      </form>
    </div>
    Login or Signup to reply.
  3. I have added onclick="seltab(this); to each image, which on click goes to respective tab and also captures what is clicked.

    (function($) {
      "use strict";
      var sdm = function() {
        var o = this;
        $(document).ready(function() {
          o.initialize();
        });
      };
      var p = sdm.prototype;
      p.initialize = function() {
        this._initChartWizard();
      };
    
    
      //Chart Wizard form
      p._initChartWizard = function() {
        var o = this;
        $('#chartwizard').bootstrapWizard({
          onTabShow: function(tab, navigation, index) {
            o._handleTabShow(tab, navigation, index, $('#chartwizard'));
            o._nextTab(o);
          }
        });
    
        $('#chartwizard').bootstrapWizard({
          'nextSelector': '.chartOption'
        });
    
      }
    
      p._handleTabShow = function(tab, navigation, index, wizard) {
        var total = navigation.find('li').length;
        var current = index + 0;
        var percent = (current / (total - 1)) * 100;
        var percentWidth = 100 - (100 / total) + '%';
    
        navigation.find('li').removeClass('done');
        navigation.find('li.active').prevAll().addClass('done');
    
        wizard.find('.progress-bar').css({
          width: percent + '%'
        });
        $('.form-wizard-horizontal').find('.progress').css({
          'width': percentWidth
        });
      }
    
      p._nextTab = function(wizard) {
        $('.nextT').click(function() {
          wizard('next');
        });
      }
    
      window.boostbox = window.boostbox || {};
      window.boostbox.sdm = new sdm;
    }(jQuery)); // pass in (jQuery):
    
    function seltab(obj) {
      var elem = obj.getAttribute('datahref')
      var click_img = obj.firstChild.getAttribute('src')
      var justifiedElems = document.getElementsByClassName('nav-justified')[0].getElementsByTagName("li");
      for (var i = 0; i < justifiedElems.length; i++) {
        if (justifiedElems[i].firstChild.getAttribute('href') == '#' + elem) {
          justifiedElems[i].firstChild.click()
        }
      }
      console.log("You Clicked " + click_img + " " + elem)
    }
    <link rel="stylesheet" href="//vinceg.github.io/twitter-bootstrap-wizard/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="//vinceg.github.io/twitter-bootstrap-wizard/prettify.css">
    <script src="//code.jquery.com/jquery-latest.js"></script>
    <script src="//vinceg.github.io/twitter-bootstrap-wizard/bootstrap/js/bootstrap.min.js"></script>
    <script src="//vinceg.github.io/twitter-bootstrap-wizard/jquery.bootstrap.wizard.js"></script>
    <script src="//vinceg.github.io/twitter-bootstrap-wizard/prettify.js"></script>
    
    
    <form role="form" id="chartwizard" novalidate="novalidate" class="form-horizontal form-bordered">
      <div class="form-wizard-nav">
        <div class="progress">
          <div class="progress-bar progress-bar-primary"></div>
        </div>
        <ul class="nav nav-justified">
          <li class="active"><a href="#tab1" data-toggle="tab"><span class="step"></span><span class="title">Chart Type</span></a>
          </li>
          <li><a href="#tab2" data-toggle="tab"><span class="step"></span><span class="title">Data Source</span></a>
          </li>
          <li><a href="#tab3" data-toggle="tab"><span class="step"></span><span class="title">Data</span></a>
          </li>
          <li><a href="#tab4" data-toggle="tab"><span class="step"></span><span class="title">Chart Options</span></a>
          </li>
        </ul>
      </div>
      <div class="tab-content">
        <div id="tab1" class="tab-pane active">
          <div class="row">
            <div class="col-sm-3">
              <div class="box">
                <div class="box-body chartOption nexT">
                  <a href="javascript:void(0);" onclick="seltab(this); return false;" datahref="tab2"><img height="100px" width="100px" src="http://placehold.it/200x150" class="img-responsive" /></a>
                </div>
              </div>
            </div>
            <div class="col-sm-3">
              <div class="box">
                <div class="box-body">
                  <a href="javascript:void(0);" onclick="seltab(this); return false;" datahref="tab3"><img height="100px" width="100px" src="http://placehold.it/200x150" class="img-responsive" /></a>
                </div>
              </div>
            </div>
            <div class="col-sm-3">
              <div class="box">
                <div class="box-body">
                  <a href="javascript:void(0);" onclick="seltab(this); return false;" datahref="tab4"><img height="100px" width="100px" src="http://placehold.it/200x150" class="img-responsive" /></a>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div id="tab2" class="tab-pane">
    
          <div align="center">
            tab2
            <img height="100px" width="100px" src="http://placehold.it/200x150" class="img-responsive" /></div>
        </div>
        <div id="tab3" class="tab-pane">
    
          <div align="center">
            tab3
            <img height="100px" width="100px" src="http://placehold.it/200x150" class="img-responsive" /></div>
        </div>
        <div id="tab4" class="tab-pane">
          <div align="center">
            tab4
            <img height="100px" width="100px" src="http://placehold.it/200x150" class="img-responsive" /></div>
        </div>
      </div>
      <div class="pager wizard">
        <li class="previous first"><a href="javascript:void(0);">First</a>
        </li>
        <li class="previous"><a href="javascript:void(0);">Previous</a>
        </li>
        <li class="next last"><a href="javascript:void(0);">Last</a>
        </li>
        <li class="next"><a href="javascript:void(0);">Next</a>
        </li>
      </div>
    </form>

    Here I assume three image corresponds to three tabs

    Login or Signup to reply.
  4. (function($) {
    "use strict";
    var sdm = function() {
        var o = this; 
        $(document).ready(function() {
            o.initialize();
        });
    };
    var p = sdm.prototype;
    p.initialize = function() {
      this._initChartWizard();
    };
    
    
    //Chart Wizard form
    p._initChartWizard = function () {
      var o = this;
      $('#chartwizard').bootstrapWizard({
        onTabShow: function (tab, navigation, index) {
          o._handleTabShow(tab, navigation, index, $('#chartwizard'));
          o._nextTab(o);
        }
      });
    
      $('#chartwizard').bootstrapWizard({ 'nextSelector': '.chartOption' });
      
       $('img').on('click', function() {
         var step = $(this).attr('data-step');
         $('#chartwizard').bootstrapWizard('show', step);
      });
    
    }
    
    p._handleTabShow = function (tab, navigation, index, wizard) {
      var total = navigation.find('li').length;
      var current = index + 0;
      var percent = (current / (total - 1)) * 100;
      var percentWidth = 100 - (100 / total) + '%';
    
      navigation.find('li').removeClass('done');
      navigation.find('li.active').prevAll().addClass('done');
    
      wizard.find('.progress-bar').css({ width: percent + '%' });
      $('.form-wizard-horizontal').find('.progress').css({ 'width': percentWidth });
    }
    
    p._nextTab = function(wizard) {
      $('.nextT').click(function(){
        wizard('next');
      });
    }
    
    window.boostbox = window.boostbox || {};
    window.boostbox.sdm = new sdm;
    }(jQuery)); // pass in (jQuery):
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap-wizard/1.2/jquery.bootstrap.wizard.min.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
    
    <div id="chartwizard" class="form-wizard form-wizard-horizontal">
    <form role="form" novalidate="novalidate" class="form-horizontal form-bordered">
      <div class="form-wizard-nav">
        <div class="progress">
          <div class="progress-bar progress-bar-primary"></div>
        </div>
        <ul class="nav nav-justified">
          <li class="active"><a href="#tab1" data-toggle="tab"><span class="step">1</span><span class="title">Chart Type</span></a>
          </li>
          <li><a href="#tab2" data-toggle="tab"><span class="step">2</span><span class="title">Data Source</span></a>
          </li>
          <li><a href="#tab3" data-toggle="tab"><span class="step">3</span><span class="title">Data</span></a>
          </li>
          <li><a href="#tab4" data-toggle="tab"><span class="step">4</span><span class="title">Chart Options</span></a>
          </li>
        </ul>
      </div>
      <div class="tab-content">
        <div id="tab1" class="tab-pane active">
          <div class="row">
            <div class="col-sm-3">
              <div class="box">
                <div class="box-body chartOption nexT"><a href="javascript:void(0);"><img src="https://placeholdit.imgix.net/~text?txtsize=20&txt=1&w=50&h=50" class="img-responsive" data-step="1"/></a>
                </div>
              </div>
            </div>
            <div class="col-sm-3">
              <div class="box">
                <div class="box-body"><a href="javascript:void(0);"><img src="https://placeholdit.imgix.net/~text?txtsize=20&txt=2&w=51&h=50" class="img-responsive" data-step="2"/></a>
                </div>
              </div>
            </div>
            <div class="col-sm-3">
              <div class="box">
                <div class="box-body"><a href="javascript:void(0);"><img src="https://placeholdit.imgix.net/~text?txtsize=20&txt=3&w=52&h=50" class="img-responsive"  data-step="3"/></a>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div id="tab2" class="tab-pane"><br/><br/>
          <p>Tab 2</p>
        </div>
        <div id="tab3" class="tab-pane"><br/><br/>
          <p>Tab 3</p>
        </div>
        <div id="tab4" class="tab-pane"><br/><br/>
          <p>Tab 4</p>
        </div>
      </div>
      <div class="pager wizard">
        <li class="previous first"><a href="javascript:void(0);">First</a>
        </li>
        <li class="previous"><a href="javascript:void(0);">Previous</a>
        </li>
        <li class="next last"><a href="javascript:void(0);">Last</a>
        </li>
        <li class="next"><a href="javascript:void(0);">Next</a>
        </li>
      </div>
    </form>
    </div>

    You may simply find the index of the image on click using $(this).index() and then call the $('#wizard').bootstrapWizard('show', index);

    For more flexibility, you may add a data-step atribute to the img and specify the step you want to go to. For example <img src="image-source" data-step="2" />. Then on click get the value of this attribute and pass it to this call $('#rootwizard').bootstrapWizard('show', value);

    You can do this by attaching a click handler to the images when you initialize the wizard

    p._initChartWizard = function() {
      var o = this;
      var $chartwizard = $('#chartwizard'); // cache
    
      $chartwizard.bootstrapWizard({
        onTabShow: function(tab, navigation, index) {
          o._handleTabShow(tab, navigation, index, $chartwizard);
        }
      });
    
      // set up selection saving and moving to next tab
      $('#chartwizard').find(".saveAndMoveNext").click(function() {
        o._saveAndChangeTab($chartwizard, this)
      });
    
      $('img').on('click', function() {
         var step = $(this).attr('data-step');
         $chartwizard.bootstrapWizard('show', step);
      });
    
    }
    

    Alternatively, you may get the wizards current index on click and show the next one

    $('img').on('click', function(){
       var index = $('#chartwizard').bootstrapWizard('currentIndex'),
           totalTabs = $('#chartwizard').bootstrapWizard('navigationLength');
        if(index === (totalTabs - 1)) {
            index = 0;
        } else {
            index += 1;
        }
       $('#chartwizard').bootstrapWizard('show', index);
    });
    

    OR simply call next on wizard

    $('img').on('click', function(){
        $('#chartwizard').bootstrapWizard('next');
    })
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search