foundation-sites: Abide validation statuses triggered twice.

Provided a simple form as the one from Foundation 5 Docs:

<form data-abide="ajax" id="myform">
    <div class="name-field">
        <label>Your name <small>required</small>
            <input type="text" name="users_name" required pattern="[a-zA-Z]+">
        </label>
        <small class="error">Name is required and must be a string.</small>
    </div>
    <button type="submit">Submit</button>
</form>

and a simple jQuery piece of code to handle abide validation

$('#myform').on('valid.fndtn.abide', function(e) {

    // Handle the submission of the form
    console.log(e);
});

THAT console.log is always fired twice!

Did any of you encountered the same issue? Any help please? Thank You.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 27 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Also having this issue.

As mentioned earlier it is due to the way that jQuery event namespacing works. Simple fix is to check the event namespace.

Like this:

$('form').on('valid.fndtn.abide', function(e) {
    // Fix for valid event firing twice
    if(e.namespace != 'abide.fndtn') {
        return;
    }

    // Handle form...