Giter Site home page Giter Site logo

kflorence / jquery-wizard Goto Github PK

View Code? Open in Web Editor NEW
173.0 20.0 40.0 572 KB

An asynchronous form wizard that supports branching.

Home Page: http://kflorence.github.com/jquery-wizard/

License: GNU General Public License v2.0

CSS 3.98% JavaScript 93.00% HTML 3.02%

jquery-wizard's Introduction

jQuery.wizard

$( "form" ).wizard( [ options ] );

This plugin turns a standard HTML form into a wizard by breaking it into a series of well-defined steps. The purpose of these steps is to better group related inputs, preventing the user from becoming overwhelmed at the size or complexity of a form and helping them to better understand the structure of an unfamiliar form.

Structure

The basic stucture of the wizard revolves around steps and branches, the latter being optional. A simple, linear form may only require one branch that contains all of the steps, whereas a complex form may require the use of several branches, or even nested branches. The number of steps and branches in a form is thus left entirely to the developer.

Navigation

The wizard employs an asynchronous finite-state machine that determines how to navigate through itself. This is accomplished by defining states within the wizard, which are attached to steps, along with their corresponding action. Steps without states attached will perform the default action of going to the next step in the current branch.

States

<div class="step" data-state="state">

States are attached to steps via the state attribute, as defined by options.stateAttribute. States can refer to the name of a transition function, the index of a step or the name of the branch.

Transitions

$( "form" ).wizard({
    transitions: {
        gender: function( state, action ) {
            return state.step.find( "[name=gender]" ).val();
        }
    }
});

Transitions act as a bridge between one state and another. They can be used to allow custom logic to determine where to go next and should ultimately return a step index or branch name in the wizard.

Arguments

Transitions are called with the wizard object as the context and these arguments:

  • state Object
    The current state of the wizard.

  • action Function
    The action function should be used to pass the result back to the wizard in the case that your transition function is asynchronous.

Options

Options is a map of key/value pairs that can be passed into the plugin as the first argument upon initialization. The default values are shown below:

options: {
	animations: {
		show: {
			options: {
				duration: 0
			},
			properties: {
				opacity: "show"
			}
		},
		hide: {
			options: {
				duration: 0
			},
			properties: {
				opacity: "hide"
			}
		}
	},
	backward: ".backward",
	branches: ".branch",
	disabled: false,
	enableSubmit: false,
	forward: ".forward",
	header: ":header:first",
	initialStep: 0,
	stateAttribute: "data-state",
	stepClasses: {
		current: "current",
		exclude: "exclude",
		stop: "stop",
		submit: "submit",
		unidirectional: "unidirectional"
	},
	steps: ".step",
	submit: ":submit",
	transitions: {},
	unidirectional: false,

	/* callbacks */
	afterBackward: null,
	afterDestroy: null,
	afterForward: null,
	afterSelect: null,
	beforeBackward: null,
	beforeDestroy: null,
	beforeForward: null,
	beforeSelect: null,
	create: null
}

By default the wizard will start on the first step, show and hide steps instantly, transition to the next step in the same branch as the current step if no state attribute is present and allow movement forwards and backwards.

  • animations Object
    Used to define custom transition animations on step changes. For more information, read up on jQuery's .animate() function.

    • show Object
      The options and properties that will be used when showing a step.

    • hide Object
      The options and properties that will be used when hiding a step.

  • backward String
    A selector string used to indicate which elements to bind the backward() method to. The method will be triggered on click.

  • branches String
    A selector string used to indicate which elements are branches within the wizard.

  • enableSubmit Boolean
    Whether or not to enable the submit button on all steps.

  • forward String
    A selector string used to indicate which elements to bind the forward() method to. The method will be triggered on click.

  • header String
    A selector string used to locate the header of the wizard.

  • initialStep String, Number, Array
    Which step to display after the wizard initializes. Accepts a string representing a step or branch ID, a number representing a step index, a jQuery object or DOM element representing a step or branch, or an array of arguments to be passed to the select() method.

  • stateAttribute String
    The attribute, applied to steps, that contains the name of a state.

  • stepClasses Object
    A map of meaningful step classes. These classes will have an effect on step behavior such as enabling or disabling navigation or preventing the step from being included in overall progress.

    • current String
      The class to toggle on the currently selected step.

    • exclude String
      If this class is present on a step the step will not be included in the progress estimate. This is useful for steps that might contain explanitory or introductory text without any inputs.

    • stop String
      If this class is present on a step the forward button will be disabled.

    • submit String
      If this class is present on a step the submit button will be enabled.

    • unidirectional String
      If this class is present on a step the backward button will be disabled.

  • steps String
    A selector string used to indicate which elements are steps within the wizard.

  • transitions Object
    A map of keys representing states and their corresponding action methods.

    • default Function
      The default transition to use on steps that contain no state attribute.
  • unidirectional Boolean
    Whether or not this wizard should be unidirectional; that is allowing only forward movement.

Events

$( "form" )
    // Bind on initialization
    .wizard({
        eventHandler: function( event, state ) { ... }
    })
    // Bind at any other time
    .bind( "wizardeventhandler", function( event, state ) { ... });

Event handlers may be passed in on intialization in the options object, or they can be bound to the wizard at any time using the format wizardeventname (note that it must be in all lowercase).

  • afterBackward or wizardafterbackward
    Triggered after the wizard has completed going backwards.

  • afterDestroy or wizardafterdestroy
    Triggered after the wizard has been destroyed.

  • afterForward or wizardafterforward
    Triggered after the wizard has completed going forwards.

  • afterSelect or wizardafterselect
    Triggered after the wizard has completed selecting a new step.

  • beforeBackward or wizardbeforebackward
    Triggered before the wizard attempts to move backwards. Returning false inside of this method will prevent the move.

  • beforeDestroy or wizardbeforedestroy
    Triggered before the wizard is destroyed. Returning false inside of this method will prevent the destruction of the wizard.

  • beforeForward or wizardbeforeforward
    Triggered before the wizard attempts to move forward. Returning false inside of this method will prevent the move.

  • beforeSelect or wizardbeforeselect
    Triggered before the wizard attempts to move in any direction. Returning false inside of this method will prevent the move.

Arguments

Events are called with the wizard element as the context and these arguments:

  • event Object
    The jQuery.Event object.

  • state Object
    An object containing either the current state of the wizard (for after events) or the state the wizard will be updating to (for before events). See the state section for further information.

  • [ update ] Function This function is available on any of the before events to allow deferred cancellation of events if asynchronous processing is needed.

Methods

$( "form" ).wizard( "methodName" [, args ] );

The wizard comes with plenty of public methods to help you navigate and get at any relevent information you may need.

  • backward( [ event, howMany ] ) returns jQuery
    Step backward through the wizard.

    • event Event
      The jQuery.Event object. Used when the function is called via a trigger or event handler.

    • howMany Number
      How many steps to take backwards. Should be a positive integer greater than zero.

  • branch( [ branch ] ) returns jQuery
    Returns a branch from the wizard. If no arguments are provided, it will return the currently active branch.

    • branch String
      The ID of a branch in the wizard.
  • branches( [ branch ] ) returns jQuery
    Returns several branches in the wizard. If no arguments are provided, it will return all of the branches in the wizard.

    • branch String
      The ID of a branch in the wizard. If provided, all of the branches within the given branch are returned.
  • branchesActivated() returns jQuery
    Returns all of the activated branches in the wizard. An activated branch is defined as any branch containing a step that has been visited.

  • destroy() returns jQuery
    Completely remove the wizard functionality from the element it was attached to. This basically reverts the element to the state it was before the wizard was applied to it.

  • form() returns jQuery
    Returns the form associated with the wizard.

  • forward( [ event, howMany ] ) returns jQuery
    Step forward through the wizard.

    • event Event
      The jQuery.Event object. Used when the function is called via a trigger or event handler.

    • howMany Number
      How many steps to take forwards. Should be a positive integer greater than zero.

  • isValidStep( step ) returns Boolean
    Returns whether or not a step is valid, or contained within the wizard.

    • step String, Number, jQuery, Element
      The step to check for in the wizard. Can be an element ID, step index, jQuery object or DOM element.
  • isValidStepIndex( stepIndex ) returns Boolean
    Returns whether or not a step index is valid, or contained within the wizard.

    • stepIndex Number
      An integer representing the index of a step in the wizard.
  • select( [ event, ] step [, branch, relative, history ] ) returns jQuery
    Selects a step within the wizard.

    • event Event
      The jQuery.Event object. Used when the function is called via a trigger or event handler.

    • step String, Number, jQuery, Element
      A step in the wizard. Can be an element ID, step index, jQuery object or DOM element.

    • branch String
      The ID of the branch that contains the step. Useful of searching for a step by step index relative to a branch. This parameter may be omitted even if further arguments are needed.

    • relative Boolean
      If true, the step argument becomes an integer representing the number of steps to move forwards or backwards relative to the current step. This parameter may be omitted even if further arguments are needed.

    • history Boolean, Array
      Whether or not to track the movements between the current step and the destination step. If set to false, the history will not be kept. This means that when hitting the back button on the selected step, the user will be taken directly back to the step they were on beforehand instead of visiting any steps in between. You can specify which steps will be included in the history yourself by passing an array of step indexes that will override whatever steps the plugin actually takes.

  • state( [ step, branch, stepsTaken ] ) returns Object
    Returns an object containing the state of the wizard at a certain step, or null if the step could not be found. If no arguments are provided, returns the current state of the wizard. See the state section for further information.

    • step String, Number, jQuery, Element
      A step in the wizard. Can be an element ID, step index, jQuery object or DOM element.

    • branch String
      The ID of the branch that contains the step. Useful of searching for a step by step index relative to a branch. This parameter may be omitted even if further arguments are needed.

    • stepsTaken Array
      An array of step indexes that represent the path taken to get to the given step from the current step. This should be provided if tracking history for the generation of an accurate state.

  • step( [ step, branch ] ) returns jQuery
    Returns a step from the wizard. If no arguments are provided, it will return the currently selected step in the wizard.

    • step String, Number, jQuery, Element
      A step in the wizard. Can be an element ID, step index, jQuery object or DOM element.

    • branch String
      The ID of the branch that contains the step. Useful of searching for a step by step index relative to a branch. This parameter may be omitted even if further arguments are needed.

  • stepCount() returns Number
    Returns the number of steps in the wizard.

  • stepIndex( [ step, branch, relative ] ) returns Number
    Returns the index of a step in the wizard, or -1 of the step could not be found. If no arguments are provided, it will return the index of the currently selected step in the wizard.

    • branch String
      The ID of the branch that contains the step. Useful of searching for a step by step index relative to a branch. This parameter may be omitted even if further arguments are needed.

    • relative Boolean
      If true, the index returned will be relative to its containing branch.

  • steps( [ branch ] ) returns jQuery
    Returns steps within the wizard. If no arguments are provided, it will return all of the steps in the wizard.

    • branch String
      An ID of a branch within the wizard. If this parameter is given, all of the steps within the branch will be returned.
  • stepsActivated() returns jQuery
    Returns all of the activated steps in the wizard. An activated step is defined as one that the user has visited.

  • submit() returns jQuery
    Submits the form attached to the wizard.

State

{
    branch: [ form#defaultBranch.ui-wizard-form ],
    branchLabel: "defaultBranch",
    branchStepCount: 3,
    branchesActivated: [ "defaultBranch" ],
    isFirstStep: true,
    isFirstStepInBranch: true,
    isLastStep: false,
    isLastStepInBranch: false,
    isMovingForward: false,
    percentComplete: 0,
    step: [ div.step ],
    stepIndex: 0,
    stepIndexInBranch: 0,
    stepsActivated: [ 0 ],
    stepsComplete: 0,
    stepsPossible: 2,
    stepsRemaining: 2
}

The wizard keeps track of its current state using an object map of keys and values. This map can be accessed at any time via the state() method. It is also passed in as the second argument to event handlers. The keys and their values are outlined below.

  • branch jQuery
    The branch the wizard is currently on.

  • branchLabel String
    The label, or ID, of the currently active branch.

  • branchStepCount Number
    The total number of steps in the current branch.

  • branchesActivated Array
    An array containing all of the currently activated branch labels.

  • isFirstStep Boolean
    Whether or not the current step is the first step in the wizard.

  • isFirstStepInBranch Boolean
    Whether or not the current step is the first step in its containing branch.

  • isLastStep Boolean
    Whether or not the current step is the last step in the wizard.

  • isLastStepInBranch Boolean
    Whether or not the current step is the last step in its containing branch.

  • isMovingForward Boolean
    Whether or not the wizard is progressing forward, that is that the current step index is greater than the previous step index.

  • percentComplete Number
    A number representing the estimated percent of completion of the wizard. This is a numerical value between 0 and 100.

  • step jQuery
    The step the wizard is currently on.

  • stepIndex Number
    The index of the currently active step.

  • stepIndexInBranch Number
    The index of the currently active step relative to its containing branch.

  • stepsActivated Array
    An array containing all of the currently activated step indexes.

  • stepsComplete Number
    The number of steps in the wizard that the user has completed. These steps will be contained in the stepsActivated array, minus any steps the developer has decided to exclude.

  • stepsPossible Number
    The estimated number of steps the user could possibly activate. This is calculated by counting all of the steps in every branch the user has activated, minus any steps the developer has decided to exclude.

  • stepsRemaining Number
    The estimated difference between stepsComplete and stepsPossible.

Installation

The easiest way to install is via NPM:

npm install @kflorence/jquery-wizard

Or Bower:

bower install jquery-wizard

You can also download releases directly from github. The latest uncompressed version is available here:

Requirements

  • jQuery
    Versions 1.7.0 or higher.

  • jQuery UI
    Core and Widget, versions 1.9.0 or higher.

Compatibility

Tested and verified to work on the following browsers:

Found a bug? Submit an issue. Tested in another browser? Send me a message or fork this project and add the browser to this readme.

Integration

This plugin has been designed to integrate well with the following plugins:

License

Copyright (c) 2017 Kyle Florence
Dual licensed under the MIT and GPLv2 licenses.

jquery-wizard's People

Contributors

kflorence avatar monguz-it avatar solarmosaic-kflorence 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery-wizard's Issues

Multiple questions require branches

Let say I have a multiples branches which the next question is depending on the answer given on the previous question.

                <div class="step" data-state="color">
                    <p>Which color do you like best?</p>
                    <label for="colorPink"><input type="radio" name="color" value="pink" id="colorPink" />Pink</label>
                    <label for="colorBlue"><input type="radio" name="color" value="blue" id="colorBlue" />Blue</label>
                </div>

                <div class="branch" id="pink">
                        <p>Which severity of pink?</p>
                    <label for="darkpin"><input type="radio" name="color" value="darkpink" id="darpink" />darkpink</label>
                    <label for="lightpink"><input type="radio" name="color" value="lightpink" id="lightpink" />lightpink</label>
                </div>

                <div class="branch" id="darkpink">
                        <p>Are you sure to go for darkpink?</p>
                    <label for="yes"><input type="radio" name="color" value="yes" id="yes" />yes</label>
                    <label for="no"><input type="radio" name="color" value="no" id="no" />Blue</label>
                </div>

The function js will be based on color value

            // Example 3: Basic branching wizard
            $( "#example-3" ).wizard({
                transitions: {
                    color: function( state, action ) {
                        var branch = state.step.find( "[name=color]:checked" ).val();
                        if ( !branch ) {
                            alert( "Please select a value to continue." );
                        }
                        return branch;
                    }
                }
            });

Now the issue is , all my HTML name element will be in the same name which is 'color'. Hence when using PHP for HTTP post there is a problem.

How I go about to solve this?

How can I add another submit button for "Save and finish later"

I have a submit button for saving
but I need to add a new button if the user wants to save and finish later.

the issue is that at the final step I have both buttons (save & save and finish later) which doesn't make sens.

How can I keep only one submit button at a time ?

image

Validation doesn't work in presence of labels

I am debugging an implementation of this that has questions with labels, which looks something like this:

  <p>I plan tasks carefully.</p>
  <label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-bis11_survey_2_0">
  <input type="radio" id="option-bis11_survey_2_0" class="mdl-radio__button " name="bis11_survey_2_options" value="4" meta-options="Rarely/Never|Occasionally|Often|Almost Always/Always" meta-text="I plan tasks carefully.">
  <span class="mdl-radio__label">Rarely/Never</span>
  </label>
  <label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="option-bis11_survey_2_1">

And I've debugged it as far as to verify that when I remove the labels, the validation finally starts working:

  <p>I plan tasks carefully.</p>
  <input type="radio" id="option-bis11_survey_2_0" class="mdl-radio__button " name="bis11_survey_2_options" value="4" meta-options="Rarely/Never|Occasionally|Often|Almost Always/Always" meta-text="I plan tasks carefully.">
  <span class="mdl-radio__label">Rarely/Never</span>

I'm guessing the bug has to do with not expecting the parent of an input to be a label, but I'm not sure where to fix it (I can't find anything). Any help would be greatly appreciated!

Branch reset input selected when going back

hello....i am using your script with branch method..i have a small issue

Question 1 -A go to question 2 (Client selects option A) -B go to question 2 Question 2 (Client wants to back to question 1 to select other option—> Selects A or B from question 2 due to required value) A B

(The problem is that the selected options from question 2 are now checked and saved, is it possible to auto-reset the options you have selected when going back? How?
thank you.

Branch error messages

Hello!
I would like to display an error message next to each empty or non-valid field on each branch instead of the "alert" that is in the current example (Example 3). I was trying to add elements from Example 1 into Example 3 and I couldn't get it to work. My best guess is that I need to replace the line below with something else?

if ( !branch ) {
    alert( "Please select a value to continue." );
}

My wizard will contain both select and text fields.

Could you help me understand how to add error messages? Thank you!

Backward issue with validation

If you try to go backward in the example "Basic Wizard With Validation", it doesn't allow you to unless you have completed the required fields. This should only apply when progressing forward through the form, not backward.

Aync transitions and content

Dear KFlorence,
I'm looking for a tools to help me implement an wizard-like form filling. Your solutions seems more apropriate to me than others.

I need to collect data from user step by step when each step depends on previously entered values. Also I can't put all variants in HTML because of they quantity. I think I have to AJAX all form values to backend and get back a next step fieldset then repeat this again till finish.

I found in you library:

  • support of branches;
  • "action" parameter of "transitions" function related to asynchronous;
  • the claim of integrating jquery-wizard with jquery-form which allow to async form submit.

All of this make me sense that there is a possibility to achevie my goal with your wizard.
But I don't fully understand how to do it. May be you can point me.

Sincerely yours,
Anthony

returning to the first step

Hello,

I'm submitting my form using AJAX in a modal. The HTML of the modal is already in the DOM. After I submit my form I just dismiss the modal. So far so good.
Then when i click again to open the modal, in case someone wants to resubmit the form with other values, I reset the form and I need to send the wizard to the first step.

How can I do this (send the wizard to the first step ) ?
I'm need to do this in the success function of the AJAX.

Thanks

remove use of "backward" / "forward" buttons when using radio buttons

hi,

is there any way to remove the use of the "forward" button specifically when using a radio button to make a selection.
i am using the branched example, but do not necessarily see the need to click forward after each selection is made

i have further radio selections throughout the wizard.. a feature such as this would therefore cut down the number of interactions the user has to make in half (in order to reach the end of the wizard)..

great plugin by the way!

Wizard not working in IE8 inside with asp.net masterpage

Hello,

I'm trying to use this wizard in ASP.NET content page.

It works in both Chrome and Firefox but in IE8 it does not work - the validation and forward button not working.

Can you please check? thanks.

Regards,
Andreas

jquery validation integration - multiple forms

Hi Kyle,

Thank you for creating this wizard widget. I've implemented a version of jquery-wizard in which the steps themselves are wrapped in form elements, but I've been having problems validating the separate forms using jquery validation and was hoping you might be able to help me integrate the two. The markup looks like this:

<html>
<div class="jq-wizard" id="W1">
<div class="steps">
<form class="step" id="F1">
<input type="radio" value="0" id="f1_1" name="g1" />
<input type="radio" value="1" id="f1_2" name="g1" />
<ul class="control-group">
<li><button type="button" name="backward" class="backward btn">Previous</button></li>
<li><button type="button" name="forward" class="forward btn">Continue</button></li>
<li><button type="submit" name="process" class="submit btn">Submit</button></li>
</ul>
</form>
<form class="step submit" id="F2">
<input type="radio" value="0" id="f2_1" name="g2" />
<input type="radio" value="1" id="f2_2" name="g2" />
<ul class="control-group">
<li><button type="button" name="backward" class="backward btn">Previous</button></li>
<li><button type="button" name="forward" class="forward btn">Continue</button></li>
<li><button type="submit" name="process" class="submit btn">Submit</button></li>
</ul>
</form>
</div>
</div>
</html>

The wizard javascript looks like this:

<script>
$('#W1')
.wizard({
options: {
steps: ".step"
}
})
.bind( "wizardbeforeselect", function( event, state ) {
var $form = state.step;
var FormID = $form.attr('id');
alert("ID: "+ FormID + "\nIs Valid: " + $('#'+FormID).valid());
var is_valid = $('#'+FormID).valid();
if (!is_valid){
alert("Please select a value to continue.");
}
return is_valid;
})
</script>

The jquery validation is:

<script>
var validator = $('.step').each(function(){
$(this).validate({
rules: {
g1: "required",
g2: "required"
}
})
});
</script>

The above validates for the final form step with the 'Submit' button (that appears on the last step), but not with the 'Continue' button which appears on the previous step. I'd like to attach the validation to both buttons for every form. In other words each step (i.e. form) goes through validation, instead of at the final submit).

I've also tried using the example listed in issue #5. That did not validate for me either.

Apologies if this is the wrong place to ask this question and thanks again for building a very good and well thought out wizard interface.

Chris

Reset Wizard?

Hi,
how to reset wizard? and return to first step after submit

Thanks.

Issue Adding to Wordpress

I have this up and running on a static page, but when I try to add it to a wordpress site using a custom page template, I get this error in the console:

Uncaught TypeError: jQuery(...).wizard is not a function
at HTMLDocument. ((index):592)
at i (jquery.js?ver=1.12.4-wp:2)
at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4-wp:2)
at Function.ready (jquery.js?ver=1.12.4-wp:2)
at HTMLDocument.J (jquery.js?ver=1.12.4-wp:2)

I am not super experienced in jQuery so any help is appreciated!

Thank you so much for your help!

Question

Hey, I hate to make a new issue but I wanted to ask you a question. I have a wizard going with a couple of transitions. Here is my code. Based on the result of servicelookup, I would like to go to a specific step. This doesn't work. What should I do?

<script type="text/javascript"> $("#wrapped").wizard({ transitions: { choosetv: function( $step, action ) { var tvchoice1 = $step.find("[name=tv_choice]:checked").val(); if(tvchoice1 == 'Starter TV - $45/mo'){ return 'additionaltv'; } if(tvchoice1 == 'Advanced TV - $110/mo'){ return 'additionaltv'; } if(tvchoice1 == 'No TV - $0.00'){ return 'end'; } }, servicelookup: function( $step, action ) { var service_address=$("#service_address").val(); $.ajax({ type:'post', url:'check_service_address.php', data:{service_address: service_address}, success:function(data){ if(data == 'not_in_list\r\n'){ console.log("sorry"); return('sorry'); } if(data == 'in_list\r\n'){ console.log("congratulations"); return('internet'); } } }); } } }); </script>

Input disappeared in multiple nested branches in a single page

In a case where I have multiple nested branches on a single form, the later steps disappear.

For example, I have a color main branch with two dependent branches and another main branch for size, I noticed that the sizes main branch and all the child branch will not show.

<div class="step" data-state="color">
	<p>Which color do you like best?</p>
	<label for="colorPink"><input type="radio" name="color" value="pink" id="colorPink" />Pink</label>
	<label for="colorBlue"><input type="radio" name="color" value="blue" id="colorBlue" />Blue</label>
</div>

<div class="branch" id="pink">
	<div class="step" data-state="end">
		<p class="pink">Pink, it was love at first sight</p>
	</div>
</div>

<div class="branch" id="blue">
	<div class="step" data-state="end">
		<p class="blue">I'm blue da ba dee da ba die...</p>
	</div>
</div>

<!-- This code is not rendered -->
                    
<div class="step" data-state="size">
	<p>Which Size</p>
	<label for="sizeOne"><input type="radio" name="size" value="1" id="sizeOne" />1</label>
	<label for="sizeTwo"><input type="radio" name="size" value="2" id="sizeTwo" />2</label>
</div>

<div class="branch" id="1">
	<div class="step" data-state="end">
		<p class="pink">Size 1</p>
	</div>
</div>

<div class="branch" id="2">
	<div class="step" data-state="end">
		<p class="blue">Size 2</p>
	</div>
</div>

<!-- /This code is not rendered -->

<div class="step" id="end">
	<p>FIN.</p>
</div>

Is there a config setting that I need to change?

Thanks

Using Branching wizard with select

Hello,

I am currently writing a wizard, the first question is a select. but I always get the same issue.
[18:31:43.335] Error: [_fastForward]: Invalid step "ofmt" @ jquery.wizard.js:201

I can pass the step if the id of the branch as the same name of the data-state but i don't get the value.

Is this a bug or a i am doing something wrong.
Here is the sample:

                                   <div class="step" data-state="ofmt">
                                            <p>Which color do you like best?</p>
                                            <select name="ofmt">
                                                    <option value="1">pink<option>
                                                    <option value="2">blue<option>
                                            </select>
                                    </div>

                                    <div class="branch" id="1">
                                            <div class="step" data-state="end">
                                                    <p>This is the pink branch.</p>
                                            </div>
                                    </div>

demo request

can you please add a demo of the integration with the form,validation,autosave etc

would be hard to have a non jQuery UI version ?

Backwards broken when initialStep starts after the first page.

I have a wizard working great with custom branching and what not however I have certain situations that have me starting the wizard on the second or third wizard page. Using the initialStep variable when creating the wizard I can make it jump to that screen however when clicking the back button nothing happens.

Any help would be appreciated.

How to dynamic create steps

I need help with my script.
I've a first step where I ask:

"How many reports do you want submit?"

Now I try to find a way to create X steps as answered in the first step.

Then, if I answered 3 reports I've something like:

Step 1 - Question how many...
Step 2 - Report 1
Step 3 - Report 2
Step 4 - Report 3

"instanceof jQuery" was not true in IE 8.0.7601.17514

Hi Kyle,

At https://github.com/kflorence/jquery-wizard/blob/master/src/jquery.wizard.js#L255

The instanceof jQuery was not true in IE 8.0.7601.17514. We tested at IE 8.0.6001 and instanceof jQuery is true. Hope it was jQuery issue.And it is a really strange for our team and we found it with a specific client.

We fixed after following change:

} else if ( type === obj ) {    
     if ( needle.length ) {

But waiting for a proper fix from your side. Thanks

I can't seem to find a valid example to do step validations

There are several "untested" versions in the issues but every time I try those I get
"Uncaught TypeError: Cannot call method 'element' of undefined jquery.validate.js:104"

Here is my code
$("#shop-create").wizard({
beforeSelect : function(event, state) {
return $(state.step).valid();
},
afterSelect : function(event, state) {
$("#shop-create .progressbar").progressbar("value", state.percentComplete);
$("#shop-create .location").text("(" + state.stepsComplete + "/" + state.stepsPossible + ")");
}
}).validate();
I have also tried
$("#shop-create").wizard({
beforeSelect : function(event, state) {
return state.step.valid();
},
afterSelect : function(event, state) {
$("#shop-create .progressbar").progressbar("value", state.percentComplete);
$("#shop-create .location").text("(" + state.stepsComplete + "/" + state.stepsPossible + ")");
}
}).validate();

Thanks for this awesome plugin!

jquery-wizard "backwards" button broken in IE

The "Backwards" button for the jquery-wizard does not work properly in Internet Explorer. In IE, the button only allows you to go back one question and the button does not work again after that.

The "Backwards" button works fine in Firefox, Chrome and Safari, allowing you to go back several questions to get back to the start.

ignore of validate

there are hidden tag in form.when I open validate options ignore: '',the wizard don't work and no something error threw

remote ajax calls in the wizard

Dear,

is it available to have a remote ajax calls and RESTful calls within the wizards and also in branching based on the ajax calls.
how to do so ..

Best Regards,
Shenouda Bertel

Disable Submit Button After Click

Thanks again so much for this awesome wizard!

Not an issue, but more of a question from a javascript newb...

What's the best way to disable the "submit" button after a click to prevent duplicate submissions?

I'm using jquery validate, but the various snippets of code I've tried don't seem to work, and I can't seem to find an elegant solution that would work well with jquery-wizard.

Jeff

How to set focus to visible input fields

What a great wizard!

This isn't really an issue, but I'm trying to figure out how to set focus to the first input element on each step of the form (really only need to for text, textarea inputs in my situation).

Is there an easy way to do this?

Forcing wizard to step to next step

Hi,

i tried but was not able to force wizard to go to next step forcing him calling (so the use of next and prev is no longer needed):

$( "form" ).wizard( "methodName" [, args ] );

Maybe I do something wrong with my statement:

$( "form" ).wizard( "forward" [ event , 1 ] );

I would like to call it after my ajax post , when the success return is called.

Any tip would be appreciated.

best regards

Leo


Ps: I' m also adding my function, maybe it will make my problem more clear.

function updUrlCheck(value) {
var radioValue = $('input[id="'+value+'"]').val();
$.ajax({
type: 'POST',
url: '../private/admin/saveCheckSuervey.php',
data: 'datiPOST=' + radioValue ,
dataType: 'html',
success: function(data) {
$("#success").show();
setTimeout(function () { $("#success").fadeOut('slow');}, 2000 /* Time to wait in milliseconds /);
//new next command
$( "form" ).wizard ????
},
error: function(data) {
$("#error").show();
setTimeout(function () { $("#error").fadeOut('slow');}, 2000 /
Time to wait in milliseconds */);
}
});
}


Ps2: Also tried with:

$('#idOfTheForm').wizard('forward', event); but no way to let it go to next step.

but no way :(

Check for step's controls validity before calculating transition

Hi,
In almost all cases of branching the decision is taken by a radio button selection.
Then this selection turns mandatory and this control is required in the form.
But when you click forward in the wizard the logic first check the transition and you lose the uniform criteria in validation messages.
It could be better, check for form validation and raise the required selection in the radio button.
Sorry for my English.
Regards
Pedro.

How to Check for IsLastStep?

Wow! Still loving this wizard... this isn't an issue, but more of a question for a noob javascripter.

How would I go about checking to see if the wizard is on the last step? I need to show some specific HTML on the final page of the wizard (below the submit button).

Would it be something like the following:

$( "#quote-wizard" ).bind( "wizardafterselect", function( event, state ) {
        if (state.isLastStep) {
            $("#premier_partners").show();
        }
});

Thanks again for all your help and the awesome wizard!

Jeff

bower install jquery-wizard fails

I'm new to bower, but it doesn't seem to like the dependencies:

$ bower install jquery-wizard --save
bower jquery-wizard#* not-cached git://github.com/kflorence/jquery-wizard.git#*
bower jquery-wizard#* resolve git://github.com/kflorence/jquery-wizard.git#*
bower jquery-wizard#* download https://github.com/kflorence/jquery-wizard/archive/1.1.0.tar.gz
bower jquery-wizard#* extract archive.tar.gz
bower jquery-wizard#* invalid-meta jquery-wizard is missing "ignore" entry in bower.json
bower jquery-wizard#* resolved git://github.com/kflorence/jquery-wizard.git#1.1.0
bower jquery.ui.widget#>=1.9.0 ENOTFOUND Package jquery.ui.widget not found

History back() support ?

Hi ,
like the title said :)
i mean to be able to use the back and forward buttons of the browser to navigate the steps
that would meany any steps could be linkable and bookmarkable

very basic bookmarkable /#Step_hash ?

Transitions callbacks are launched before the "before..." events

Hello,
Thank you very much for this great plugin. I used it in some projects and it's awesome!

However, I found an issue with the order in which events are called. If there is transition callback for a given step, it is applied before the "beforeSelect" event.

jQuery("#example_form").wizard({
    "transitions" : {
        "step_1" : function (step, action) {
            console.debug('transition');
            return 'step_2';
        }
    },
    "beforeSelect" : function (event, state) {
        console.debug('beforeSelect');
        return true;
    }
});

In the example before the console prints "transition" and then "beforeSelect". Is it possible to call the transition after "before" events family? The rationale is that when the transition is used to send data to the server (partial ajax submit), and the "before" event contains the form validation logic, the validation is appied after submitting the data.

Thanks in advance and regards!

bower install jquery-wizard fails

jquery-wizard fails to install in bower 1.3.11

     [michael.moser]$ bower install jquery-wizard
     bower jquery-wizard#*       not-cached git://github.com/kflorence/jquery-wizard.git#*
     bower jquery-wizard#*          resolve git://github.com/kflorence/jquery-wizard.git#*
     bower jquery-wizard#*         download https://github.com/kflorence/jquery-wizard/archive/1.1.0.tar.gz
     bower jquery-wizard#*          extract archive.tar.gz
     bower jquery-wizard#*     invalid-meta jquery-wizard is missing "ignore" entry in bower.json
     bower jquery-wizard#*         resolved git://github.com/kflorence/jquery-wizard.git#1.1.0
     bower jquery.ui.widget#>=1.9.0        ENOTFOUND Package jquery.ui.widget not found

package.json still contains,

    "jquery.ui.core": ">=1.9.0",
    "jquery.ui.widget": ">=1.9.0"

though I am unclear if bower is utilizing this file or not

Bug wizard with tinymce (jquery version)

Hello I have an error with the integration of tinyMCE (jquery version) in a div of wizard.

firebug return error :

Error: [_fastForward]: Recursion detected on step "[object Object]" AND TypeError: classes.split is not a function

But if I remove the textarea everything is working properly

Best regards

Destroy/initiate issue

If I alternatively destroy a wizard and then initiate it, after doing so subsequent initializations cause odd behavior. Instead of showing one branch at a time, it shows n+1 branches. (So the second time it's initialized, it shows two branches for each "forward", the next time it's destroyed/initialized it shows three, etc....) Obviously something is not being reset properly in the destroy logic, but I havent yet figured out what/where it is. Any ideas?

By the way, thank you for such a useful piece of code.

ETA: Here's a jsfiddle of a subset of the page we're using, you can see the behavior by stepping through the wizard a little bit, turning off the interview (destroying the wizard) and then turning it back on , and then stepping through it again.: http://jsfiddle.net/y0w1mmkh/22/

Initialization and Double click issue

01/ when destroy and re initialize the wizard and stepping forward returns

  1. invalid step
  2. doesn't reset form values and
  3. unbind all the form validations.(that may be because values are set)

image

02/ When double click on forward/ backward buttons current step is replaced by the last step, seems we need double click disabled for buttons

Trying to fix these.

Thank You

hide or show step dynamically

Dear florence,

I need to remove or skip 1 step based on one value in the first step.
example : if user choose to make hotel reservation in the first step I want to show that step
if he don't choose that option I want to remove that step from the wizard.
is there a way to do that?

Thanks for your help.
Regards,

validation and progress together

Hi,

How can i use this plugin with validation and progress bar at the same time ?
In your example this should be example 1 with progress bar above it..

Thanks

Fix selecting steps in a complex wizard

Currently, setting initialStep to anything except the first step will not allow you to move backwards; also, selecting a step via the "select" method will skip over all of the steps in between the current step and the step you are selecting.

Need to implement a way of navigating the steps in between. We cannot assume that all of those steps will be touched, we must follow the natural flow of the wizard (including the execution of actions); this may result in the selection being invalid in cases where the actions fail.

Location of steps

Hey, I don't know if it's possible with wizard to show where you are. I know there's the progress bar, but what I want is to have a column next to form with the steps on it. The steps should only come visible or be clickable once they are on the step. (something like this: http://mstratman.github.io/jQuery-Smart-Wizard/smartwizard2-vertical.htm). If this is possible, could you put me on the way how to do this. Thx in advance.

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.