Git Product home page Git Product logo

jquery-steps's Introduction

jquery-steps

npm License: MIT npm npm

A simple, lightweight jQuery step wizard plugin.

Features

  • Easy configuration
  • Lightweight (2KB gzipped)
  • Works in all major browsers including IE11+

Compatibility

IE11+, Edge, Chrome, Firefox, Opera, Safari

Installation

NPM

npm install jquery.steps

Github

git clone http://github.com/oguzhanoya/jquery-steps.git

CDN

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery-steps.min.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery-steps.min.js"></script>

Setup

Include plugin stylesheets.

<link rel="stylesheet" href="css/jquery-steps.css">

Make necessary markup for wizard. That's all, you don't need to do anything else.

<div class="step-app" id="demo">
  <ul class="step-steps">
    <li data-step-target="step1">Step 1</li>
    <li data-step-target="step2">Step 2</li>
    <li data-step-target="step3">Step 3</li>
  </ul>
  <div class="step-content">
    <div class="step-tab-panel" data-step="step1">
      ...
    </div>
    <div class="step-tab-panel" data-step="step2">
      ...
    </div>
    <div class="step-tab-panel" data-step="step3">
      ...
    </div>
  </div>
  <div class="step-footer">
    <button data-step-action="prev" class="step-btn">Previous</button>
    <button data-step-action="next" class="step-btn">Next</button>
    <button data-step-action="finish" class="step-btn">Finish</button>
  </div>
</div>

Include plugin and dependeces. jQuery is the only dependency, make sure to include it.

<script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js"></script>
<script src="js/jquery-steps.js"></script>

Init plugin with choosen options.

<script>
  $('#demo').steps({
    onFinish: function () { alert('complete'); }
  });
</script>

Configuration

Setting Default Value Description
startAt 0 Starts wizard at specifed step number.
showBackButton true Indicates whether the back button will be visible.
showFooterButtons true Indicates whether the footer buttons will be visible.
stepSelector .step-steps The selector used for each step.
contentSelector .step-content The selector used for the step content.
footerSelector .step-footer The selector used for the buttons.
activeClass active The class used when a step is active.
doneClass done The class used when a step is done.
errorClass error The class used when an error occurs in a step.
onInit function(){} Fired when plugin is initialized.
onChange function(currentIndex, newIndex, stepDirection){return true;} Fired when plugin step changed.
onFinish function(){} Fired when plugin wizard finished.
onDestroy function(){} Fired when plugin destroy.

Methods

Name Description
destory Destroy the plugin instance.
next Goes to the next step.
prev Goes to the previous step.
finish Trigger the onFinish event.
getStepIndex Gets the current step index.(start from 0)
getMaxStepIndex Gets the max step index.
setStepIndex Sets the step index.

License

MIT

jquery-steps's People

Contributors

log1x avatar oguzhanoya avatar roilti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

jquery-steps's Issues

Use data attributes to tie steps to the headers.

I am forced to include an anchor tag in my <li> which I do not want to do. Why cant we just do:

<li data-step-target="step1">
<li data-step-target="step2">

And later:

<div class="step-content" data-step-id="step1">
<div class="step-content" data-step-id="step2">

Does this hut accessibility?

Publish to npm

I was curious if you'd mind publishing jquery-steps to npm? It looks like the name jquery-steps is taken, but you could change name in package.json to jquery.steps which is available and then npm publish and it'd allow for much easier package management when using webpack.

WordPress: Uncaught TypeError: can't access property "noop", $ is undefined

Hi,
I am trying to get this working inside WordPress but keep getting this error:

Uncaught TypeError: can't access property "noop", $ is undefined and also

Uncaught TypeError: $(...).steps is not a function

The dist/jquery-steps.js is loading as depending on jQuery but still get this error. WordPress is running jQuery 3.5.1.
I already tried setting up de init script as below, but still getting the error. Do you have any advice?

<script> jQuery( document ).ready(function($) { $('#demo').steps({ onFinish: function () { alert('complete'); } }); }); </script>

Bug with switching to next select2 selector.

I have few steps. When I switch to next dropdown selector is cutted to 1px. Only 1st selector displays correctly.
Someone had this bug before?
image

    $('#demo').steps({
        onFinish: function(1, 2, forward){return true;}
    });

Error : Uncaught SyntaxError: Unexpected number

demo sayfası

bu demo sayfasının kodlarını paylaşbilir misin hocam güzelmiş
birde oraya diğer örnekleride atarsan bence tadından yenmez

Clashing with Contact Form 7 signature canvas

I've installed the scripts and got the steps working - however, this causes the signature option in contact 7 to stop functioning and doesn't allow you to draw a signature.

If I remove the scripts for steps it works again so it does seem to be clashing with it.

There aren't any errors to work with which is frustrating.

Support for async validation

Hi

Thank you for this amazing library.

In a new web app I have to create dynamic tabs with dynamics fields in them. I don't know how many tabs there are, and I don't know how many fields exists in each tab.

Thus on clicking next, I have to raise an event ( validationRequested) and wait for all fields of the current tab to validate and return. Some of those fields need to validate based on server, thus they might take even some seconds before validation results can be known.

Here's the code I come up with. But it does not work:

onChange: function (currentIndex, newIndex, stepDirection) {
	if (stepDirection === "backward" || stepDirection === "none") {
		return true;
	}
	if (app.allowChangeToNextStep) {
		app.allowChangeToNextStep = false;
		return true;
	}
	var stepFields = app.findScopeFields($('#wizardForm .step-tab-panel[data-step=step' + (currentIndex + 1) + ']'));
	var fieldsThatNeedValidation = app.filterFieldsThatNeedValidation(stepFields);
	app.validateForm(fieldsThatNeedValidation)
		.then(function (submissionResults) {
			if (submissionResults.success) {
				app.allowChangeToNextStep = true;
				wizard.data('plugin_Steps').next();
			}
			return false;
		})
		.catch(function (error) {
			console.error(error);
		});
	return false;
},

This causes to go forward two steps.

Can you provide built-in support for async scenarios?

onChange fired twice

For me, with the demo setup and hooking into the onChange event, the 'validate!' alert is showing 2 times when hitting next from step 2.

  <script>
    $('#wizard').steps({
      onFinish: function() {
        alert('yo');
      },
      onChange: function(currentIndex, newIndex, stepDirection) {
        if( stepDirection == 'forward' ) {
          alert('validate!');
        }
        return true;
      }
    });
  </script>

WordPress and jQuery.noConflick() breaks plugin

Yesterday, I tried to integrate this plugin into a WordPress site, and it failed. Upon investigating I found the plugin fails if jQuery.noConflict() is called. So, I tested it with stock jQuery from the jQuery site and added a noConflit and bam the same noop error.

Uncaught TypeError: Cannot read properties of undefined (reading 'noop')

It's the same closed issue posted at #19
But it isn't resolved actually.

onChange fired nubmer of the newIndex

with the demo setup and hooking into the onChange event, the 'validate!' alert is showing console.log() result depend on the number of the newIndex when hitting next from step 2.

 $('#demo').steps({
            onChange: function (currentIndex, newIndex, stepDirection) {
                if (stepDirection == 'forward') {
                    console.log("currentIndex " + currentIndex + " newIndex " + newIndex + "")
                }
                return true;
            },
            onFinish: function () {
                console.log("finished")
            }
        });

onChange function issue

When add any logics (alert, console.log or call APIs) in "onChange" function, they will be carry out twice...I just use the alert do this test, I found when trigger onChange function, the alert will be show twice, could u please help to fix this issue?

Back to the first page, when returning false in the 4th index page

When I try to return false when in the 4th index page to hold it to the next step, it goes directly to the first page, is there a way when the return false function stays on the current page ?

Here is the code condition, each function reverses a boolean value :

onChange: function onChange(currentIndex, newIndex, stepDirection) {
	    index = newIndex;
	      if (index==1){
	      		return sendData1();
	      } else if (index==2){
	      		return sendData2();
	      } else if (index==3){
	      		return sendData3();
	      } else if (index==4){
	      		return sendData4();
	      } else if (index==5){
	      		return sendData5();
	      } else if (index==6){
	      		return sendFinalData();
	      }
	  	  return true;
	    }

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.