Giter Club home page Giter Club logo

Comments (7)

ilfrich avatar ilfrich commented on June 26, 2024

Ha! Just before I gave up, I tried one last thing:

The end function of the summary output mode first hides the container, then checks for buffer.length (which in my case was 0 for the last 2 validations, but even with a check for (buffer.length > 0) it triggered the code inside for the 0 length buffer (according to my console outputs).

So even, if there was no error it triggered $(container).show() - in my case an empty error container.

Now I've wrapped the display section:

if ($(container + " label").size() > 0) {
$(container).show();
}

and it finally works (I'm using s instead of

  • s).

    What I still don't understand is why the buffer might not be empty at the if, but is empty when it iterates to generate the error messages. Could this be a timing/parallelization problem? Because I trigger the validation too quickly the validations overlaps and I'm looking at the wrong buffer?

  • from validity.

    whatgoodisaroad avatar whatgoodisaroad commented on June 26, 2024

    Sorry about being so late to respond to this. Do you mean that 0 is evaluating as True? That seems very strange!

    Perhaps it's related to the way your output is different. For example, in the normal summary output, it deletes all the <LI>s, but you appear to be using <LABEL>s. Maybe if you change...

    // Hide the container and empty its summary.
    $(container)
        .hide()
        .find("ul")
            .html('');
    

    ...to...

    // Hide the container and empty its summary.
    $(container)
        .hide()
        .html('');
    

    from validity.

    ilfrich avatar ilfrich commented on June 26, 2024

    Hi, I've tried that. It didn't work.
    As I said, it only occurred when I've filled out a form with JS and had a change-event on each input/select, which triggered the entire form validation. So filling out triggered the validation very quickly say 10 times in a row.

    I'll try to put together an example.

    from validity.

    whatgoodisaroad avatar whatgoodisaroad commented on June 26, 2024

    Oh, I see what you mean! Yes, this is likely related to overlapping validation sessions. Maybe it would be different if, in your input change handler, you called end just before you call start again.

    from validity.

    ilfrich avatar ilfrich commented on June 26, 2024

    You mean blocking the re-validation by some token until the previous validation is finished?
    I put together this to demonstrate (I've copied my output method in there).

    http://jsfiddle.net/NLZXM/3/
    Click Submit to trigger the validation and then "fill out form" to populate values.

    from validity.

    whatgoodisaroad avatar whatgoodisaroad commented on June 26, 2024

    Thanks for the example. That's very helpful! I think I've found the problem and I have a fix.

    The issue is that the fadeIn function uses an interval, so, sometimes, even though the div has been hidden, the interval to fade it in is still running!

    We can fix this by changing line 35 of your JS code to...

    $(container).stop().hide().html('');
    

    Adding the call to stop kills the interval for fading in.

    This is definitely something that should be present in the normal summary output, so thanks a lot for this catch!

    from validity.

    ilfrich avatar ilfrich commented on June 26, 2024

    Thanks a lot for your help! This finally solves my problem without any dirty code :)

    And congrats to this great validation plugin. I've evaluated a couple of them and Validity turned out to be very lightweight and is still very powerful and flexible.

    from validity.

    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.