Closed rob101 closed 3 years ago
Awesome report! I'll try to have a better look at it later today, but I see a bunch of typos "parsely <=> parsley" (I do the same all the time!).
@marcandre Yes, embarrassing! These were in the variable name declarations though, so doesn't affect the logic. I've corrected the code and the error still reproduces. Thanks
The HTML still had one typo.
The global config setting was the issue. No need for the refresh
, parsley automatically rechecks the constraints upon validation. Here's a Codepen that shows it in action: https://codepen.io/marcandre/pen/yLeYBZw
Thanks. The annotated source (link) has:
window.ParsleyConfig = Parsley.options; // Old way of accessing global options
But there doesn't seem to be a reference to the correct way to set options the "new" way. window.Parsley.options = {}
doesn't seem to work. How do you set trigger in a dict
with other options like errorClass
, errorsWrapper
, etc?
Right, you can't replace the object used, just modify it. Use $.extend
:-)
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 tag
parsley.js
.[X ] 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.
Problem When changing field attributes dynamically,
parsley().refresh()
does not reload the form and bind parsley field attributes.Example
Consider the codepen here: https://codepen.io/alias51/pen/rNxVQXw.
ParsleyJS is loaded via the
data-parsley-validate
attribute of the form$('#parsley_form')
on page load, however no inputs on the form have any validators set at this stage.If
data-parsley-required
attribute is added to a field dynamically (by an onclick event listener for$('#enable')
, then it will validate and throw and error on form submit.If we call
$('#form_parsley').parsley().refresh()
on the form before submit, then the expected behaviour would be that the field is bound to the Parsley instance and thechange
trigger should apply as if thedata-parsley-required
attribute was present at page load. However, it does not: for example, click "Enable Parsley" and then add input to the field, remove it, and change the focus. No error is thrown.parsley().refresh()
does not behave as expected.