问题
Have a an upload form with some required fields which uses parsley.js to validate. I want to display a loading gif after the form has been validated and the actual uploading starts.
I've tried using an onsubmit event to call a function which changes the visibility of the loading gif from hidden to visible. But the gif shows up when ever the upload button is clicked even if the form has not been validated.
Thanks in advance!
回答1:
You'll have to use Parsley events (http://parsleyjs.org/doc/index.html#psly-events-list) and do something like that:
$('#form').parsley().subscribe('parsley:form:validated', function (parsleyForm) {
if (true === parsleyForm.validationResult )
// display gif
else
// do something else, or nothing
});
Best
来源:https://stackoverflow.com/questions/23081887/display-loading-gif-after-parsley-js-validates-form