8000 [ equalTo ] bind `blur` event only once to the target of `equalTo` rule · Issue #1707 · jquery-validation/jquery-validation · GitHub
[go: up one dir, main page]

Skip to content
[ equalTo ] bind blur event only once to the target of equalTo rule #1707
Closed
@Arkni

Description

@Arkni

From #1704:

  • @staabm:

we should use .one()[1] to fix that TODO. but this will also not clear the event listener on destroy

[1] http://api.jquery.com/one/

  • me:

we should use .one()[1] to fix that TODO.

I think it's the same as using .off( ... ).on( ... ) but more readable.
It's not equivalent to off( ... ).on( ... ) in the use case of equalTo rule. The event should still there in order to validate the element (which equalTo rule was attached to) after every focus out of the target.
IMO, the goal of that TODO is to bind the event once for all without unbinding it every time.
Anyway, until there is a better solution, using one( ... ) makes more sense here.

but this will also not clear the event listener on destroy

We have to add it, then.


The problem here is, every time the element was validated, the event was (un)binding from|to target.
Even if we use .one( ... ), the only benefit is making the code more readable and simple.

//Cc @staabm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0