Git Product home page Git Product logo

Comments (6)

luksak avatar luksak commented on May 12, 2024 1

I was able to accomplish this functionality using this Code:

$wizard = $("#wizard");
$wizard.steps({
  onStepChanged: function (event, currentIndex, priorIndex) {
    var currentStep = $("#wizard").steps("getStep", currentIndex);
    window.location.hash = currentStep.title;
  }
});


$(window).hashchange( function(){
  var hash = location.hash.replace("#", "");

  $steps = $wizard.data("steps");

  if (hash == "") {
    var firstStep = $wizard.steps("getStep", 0);
    hash = firstStep.title;
  }

  jQuery.each($steps, function (indexInArray, valueOfElement) {
    if (valueOfElement.title == hash) {

      var $currentIndex = $wizard.steps("getCurrentIndex");
      var diferrence = indexInArray - $currentIndex;

      for (var i = 0; i < diferrence; i++) {
        $wizard.steps("next");
      }

      for (var i = 0; i > diferrence; i--) {
        $wizard.steps("previous");
      }
    }
  });
});

Of course it is not well written JS, but it does the trick for the moment. How can we get this functionality into jQuery Steps?

I was missing two API methods:

$steps = $wizard.data("steps");

This doesn't seem to be the nicest to accomplish what I needed. Why not introduce a getSteps() method?

var $currentIndex = $wizard.steps("getCurrentIndex");
var diferrence = indexInArray - $currentIndex;

for (var i = 0; i < diferrence; i++) {
  $wizard.steps("next");
}

for (var i = 0; i > diferrence; i--) {
  $wizard.steps("previous");
}

This isn't nice either. The only way to navigate through steps are the next() and previous() methods. Why not have something like goToStep() which takes the desired index as a parameter?

from jquery-steps.

rstaib avatar rstaib commented on May 12, 2024

Hi @quasiperfect,

could you explain that a bit more and tell me what the benefit would be please!? Would be super cool ;-)

from jquery-steps.

quasiperfect avatar quasiperfect commented on May 12, 2024

Hi @rstaib ,

i mean to be able to use the back and forward buttons of the browser to navigate the tabs
that would meany any tab could be linkable and bookmarkable

take a look here http://benalman.com/projects/jquery-hashchange-plugin/

from jquery-steps.

rstaib avatar rstaib commented on May 12, 2024

Hey @quasiperfect,

now it is clear to me. Sounds great and thx for contribution! I will implement that in one of my upcoming releases. And actually, it is related to one of my next features where you could jump from any page to a specific step.

I will inform you when it is ready for use.

from jquery-steps.

quasiperfect avatar quasiperfect commented on May 12, 2024

hi @rstaib,

thanks for your work

from jquery-steps.

luksak avatar luksak commented on May 12, 2024

I just did a build and failed to see the desired behavior except that changing steps also changes the hash. Navigating to a specific step using a hash in the URI doesn't work.

What is missing here? Maybe I could try to contribute this.

from jquery-steps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.