JavaScript API for WordPress NinjaForms before submission
I am using WordPress Ninja Forms and I am trying to create a preview of a form to be accepted before submitting data via Ajax. This means I need to add custom JS code between the form validation and the submit process.
So far I have tried the following:
var form_id = 1;
var PreviewFormController = Marionette.Object.extend({
initialize: function() {
Backbone.Radio.channel( 'form-' + form_id ).reply( 'maybe:submit', this.PreviewForm, this, form_id);
},
PreviewForm: function(formID){
var formModel = nfRadio.channel( 'app' ).request( 'get:form', formID );
if(formModel.getExtra('previewOk')){
return true;
}
this.ShowPreview( formModel );
return false;
},
ShowPreview: function(formModel){
if(confirm("You sure?")){
nfRadio.channel( 'form-' + form_id).request( 'add:extra', 'previewOk', true );
nfRadio.channel( 'form-' + formModel.get( 'id' ) ).request( 'submit', formModel );
}
}
});
$(function(){
new PreviewFormController();
});
The problem is that PreviewForm
now comes before field validation. How can you connect the function after checking the field?
I am a bit lost as the Codex is not ready yet. I would be so glad if someone could help me.
+3
source to share
No one has answered this question yet
Check out similar questions: