Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeoberdick/35c9c2b53b21c9b6902278c3376eb5f1 to your computer and use it in GitHub Desktop.
Save mikeoberdick/35c9c2b53b21c9b6902278c3376eb5f1 to your computer and use it in GitHub Desktop.
Dynamically grab field values from Ninja Form fields on submit
<script>
var getQuoteFields = Marionette.Object.extend( {
initialize: function() {
this.listenTo( Backbone.Radio.channel( 'forms' ), 'submit:response', this.actionSubmit );
},
actionSubmit: function( response ) {
$sqFootage = response.data['fields'][15]['value'];
//Remove the hypens and replace with spaces
$county = response.data['fields'][10]['value'].replace(/-/g, " ");
jQuery('#squareFootage').text($sqFootage);
jQuery('#county').text($county);
console.log($county);
},
});
// Instantiate our custom field's controller, defined above.
new getQuoteFields();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment