I have a react app with many different forms I'm looking to not have to write the same code over and over for each form, and I'm looking for a simple way to centralize the onSubmit()
handlers for all forms. From a central location I can trigger the specific Flux action that will trigger an ajax call.
I'm picturing one function that takes care of all form requests.
function (event) {
event.preventDefault()
var $elm = $(event.target)
var d = {}
d.method = $elm.attr('method')
d.action = $elm.attr('action')
d.data = $elm.serialize()
console.log(d)
}
From here I can check the action
and method
and make a switch for each possibility.
Does this make sense within the Flux architecture?