Here is a simple example: http://codepen.io/spacejaguar/pen/KrvqNW
HTML:
<form data-parsley-validate>
<label for="name">Name:</label>
<input type="text" name="name" required>
<br>
<input type="submit" value="validate">
<p><small>This is a simplistic example, good to start from when giving examples of use of Parsley</small></p>
</form>
and js
$(function () {
$('form').parsley()
.on('form:init', function() {
console.log('Form init', arguments);
})
.on('field:init', function() {
console.log('Field init', arguments);
})
.on('form:validate', function() {
console.log('Form validate', arguments);
})
.on('form:submit', function() {
return false;
});
});
It seems that the form: init or : init callback functions are not called at all, and any other works fine. What am I doing wrong? Or maybe this is a mistake?
[EDIT]
I searched the source code and did some debugging stuff, it seems that the init event is fired before any listener is connected. Creating an instance of the parsley element looks the same:
- $. fn.parsley
- ParsleyFactory, init fn
--- ParsleyFactory.prototype.init .., bind fn
---- ParsleyFactory.prototype.bind , (ParsleyForm, ParsleyField ParsleyMultiple)
----- ParsleyForm
---- ParsleyFactory.prototype.bind init
--- ParsleyFactory.prototype.init
- ParsleyFactory - $. fn.parsley
- .on('field: init', function() {...})