Last active
January 25, 2020 04:32
-
-
Save zaxbux/8478eeb8e4a11a2dc30f355842291f15 to your computer and use it in GitHub Desktop.
Modify request data before submit (October CMS Backend forms)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Listen to AJAX setup event | |
// This event is fired before request is formed | |
// Allows the request data to override input values | |
// Useful for custom controls, input masks, etc | |
$(window).on('ajaxSetup', function (e, context) { | |
// Find the form and inputs from e.target (the submit button) | |
// Select specific forms and inputs by modifying $('form') and $('input') | |
$(e.target).closest('form').find('input').each(function() { | |
var inputName = $(this).attr('name'), | |
inputValue = $(this).val(); | |
// Modify inputValue here | |
// ... | |
// Set the modified value | |
context.options.data[inputName] = inputValue; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment