`whenValidate` not affecting UI
richard-jones opened this issue · comments
What kind of issue is this? (put 'x' between the square brackets)
-
Question. This issue tracker is not the place for questions. If you want to ask how to do
something, or to understand why something isn't working the way you expect it to, use
http://stackoverflow.com/questions/ask .
Provide working code, starting from http://codepen.io/marcandre/pen/jqbzyN?editors=101.
We monitor the tagparsley.js
. -
Bug report. If you’ve found a bug, you must provide a minimal example in a CodePen,
starting from http://codepen.io/marcandre/pen/jqbzyN?editors=101 . -
Feature Request. Make sure there's no good way to do what you want first;
consider asking on http://stackoverflow.com/questions/ask first.
I am making the following call
this.form.parsley().whenValidate().done(() => {
this.jq("#cannot-submit-invalid-fields").hide();
}).fail(() => {
this.jq("#cannot-submit-invalid-fields").show();
});
(where this.form
is a reference to a jQuery element for the form).
On fail
a message is shown to the user saying that they cannot submit. As I am using whenValidate
, I am also expecting the UI to update to highlight the invalid field, and provide validation error messages.
What actually happens when I run this is that the message is shown to the user as expected, but the UI is not updated with the parsley errors.
On the parsley object, there is a property validationResult
and it has the value false
. I looked in the fields
property of the parsley object, and I could not see any invalid fields:
>>> parsley.fields.filter(x => !x.validationResult)
Array []
(where parsley
is the result of calling this.form.parsley()
above, and then running whenValidate
)
I wonder if this lack of invalid fields is the reason the UI has not been updated. What I can't work out is how I can get a validation failure, but have no invalid fields. I do have invalid fields, and I'm trying to get them to be highlighted.
My bad, this was a very oblique bug in a custom validator that was causing a reset
on the parsley field under certain circumstances, and giving the impression that the UI was not updated. In fact the UI was updated and reset all so quickly that you couldn't tell. Sorry for the noise!