thecodemine / formwizard

jQuery plugin based on top of jQuery UI which turns a form into a multistep wizard. Integrates with the jQuery form plugin for AJAX submission of the form, the validation plugin for client side validation and the BBQ plugin for enabling the browsers back and forward buttons.
140 stars 54 forks source link

Ability to override the attribute used for linking steps #12

Closed AlexKeySmith closed 13 years ago

AlexKeySmith commented 13 years ago

Hi, Just to begin, awesome plugin thecodemine, keep up the good work.

I have a small tweak taht you might like, around times when you may not wish to use an element's value to indicate the next step.

For example by default a link from a radio button would use it's value, but in some cases you may wish to have a different value to the id of the next step, for example for boolean inputs, where you may want to submit 1 / 0 rather than a string.

<input type="radio" name="mandatory" value="1"/>
<input type="radio" name="mandatory" value="0"/>

In this situation instead of using the value attribute (the default), you could use the rel.

With this you could now have something like:

  $("#pushRuleWizard").formwizard({
            linkAttr: "rel"
        });
<input type="radio" name="mandatory" value="1" rel="addMandatoryResourcesStep"/>
<input type="radio" name="mandatory" value="0" rel="addOptionalResourcesStep" />
stockcer commented 13 years ago

This is a very cool script, I have having a problem with the validation. It looks like the latest version of jquery library 1.6.1 does not trigger the validation correctly when moving to a new tab. It works great when I using 1.4.2.

If the validation fails it will not move to the next step but it will not display the error message associated with the validation.

AlexKeySmith commented 13 years ago

Thanks for the comment stockcer, however "in theory" my modifications shoudn't of affected the validation.

The functionality I've added has just tweaked the existing switch tab branching.

The formwizard could already move between tabs based upon the value of an input. i.e. on this branching example: http://thecodemine.org/examples/example_2_branch.html

I'd just made it so you don't need to use the "value" attribute and instead could specify your own attribute e.g. "rel".

Perhaps if you've found a problem with the validation it's an issue with the main formwizard code?

Having said this, if the problem is with my tweak, please let me know.

AlexKeySmith commented 13 years ago

On a slightly different note, I'm starting to see problems with my proposal. Although it's nice to be able to use another attribute, looking closer over the html specs I think I'm misusing the "rel" attribute as it doesn't exist on an input tag and only exists on an "a" or "link" element.

I may modifiy the code so instead of using a different attribute it could use the jquery meta data plugin http://plugins.jquery.com/project/metadata