在Parsley表示表单有效后,将使用“接受/拒绝”按钮向用户显示模式对话框。单击“接受”后,表单将被提交,但不会发生。
// Show the modal dialog before signing up.
$('form#new_user').on('submit', function(e) {
if ($('input#user_nda_accepted').val() !== 'true') {
return false;
}
});
$.listen('parsley:form:validated', function(formInstance) {
if (formInstance.isValid()) {
$('body').addClass('modal--open');
}
});
// Submit the form on Accept, hide the modal on Decline.
$('.js-nda-accept').on('click', function(e) {
e.preventDefault();
$('input#user_nda_accepted').val('true');
$('form#new_user').off('submit.Parsley').trigger('submit');
});
$('.js-nda-decline').on('click', function(e) {
e.preventDefault();
$('input#user_nda_accepted').val('false');
$('body').removeClass('modal--open');
});