Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normal triggers no more binded after first failure #1287

Closed
wants to merge 1 commit into from
Closed

Normal triggers no more binded after first failure #1287

wants to merge 1 commit into from

Conversation

Marco-Sulla
Copy link
Contributor

There was an else after if (this._failedOnce). This way the binds on normal triggers were not rebinded if the field has failed once.

There was an else after `if (this._failedOnce)`. This way the binds on normal triggers were not rebinded if the field has failed once.
@marcandre
Copy link
Collaborator

This is intended. We want to bind on either the "normal" trigger, or the "after error" trigger, but not both.
You can always list multiple evens in the triggers, so you can include your normal trigger in the after error if this is causing you an issue.

@marcandre marcandre closed this Mar 14, 2019
@Marco-Sulla
Copy link
Contributor Author

I must say the name of the property, data-parsley-trigger, is highly misunderstandable. It seems the validation is triggered every time the event is fired, and not only if no error was fired before.

IMHO it's more useful to add a data-parsley-trigger-always that binds the events every time.

@marcandre
Copy link
Collaborator

I understand your point, but I would suspect that for most cases, the afterFailure events are usually enough. That's the case for the defaults. Which events are you using?

@Marco-Sulla
Copy link
Contributor Author

Marco-Sulla commented Mar 14, 2019

Usually input and change for date and select inputs. The fact is that we are using bootstrap datepicker and datetimepicker for dates, and SumoSelect (for old projects) and bootstrap select2 for new ones. I checked the source code of these projects and they triggers only the change event. So data-parsley-trigger-after-failure, that I ignored because I thought data-parsley-trigger was enough, fires nothing because it defaults to the input event only.

I think afterFailure is useful only after a failed submit, but IMHO it's more useful to be immediately informed that the input I compiled is wrong. The majority of modern sites work this way.

PS: I also set Parsley.options.validationThreshold = 0, I think it's much more useful and it's highly confusing that the error is not immediately displayed. An high value is good for text inputs, but for the majority of cases is only a cause of misunderstandings.

@marcandre
Copy link
Collaborator

At the risk of sounding not pragmatic enough, I don't want to design an API to circumvent bugs, especially in more or less unmaintained libraries (e.g. I created a PR for select2 more than 2 years ago). Another way to say this is that, assuming we ignore bugs of libraries, there are no use case for the feature you are requesting.

I'm sorry you have issues with the input event, but the fact is, it is the exact event that should be used for validation, so I would recommend to circumvent the issues it by triggering these inputs event yourself instead of the defective libraries. This way, you get closer to how things should work.

Alternatively, set afterFailure to "change input".

BTW, I applaud your effort to improve things (like creating this issue and having this discussion), and I encourage you to voice your support for fixing things that are actually broken, like better browser support or the PR for select2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants