UI Enhancements
It would be nice if the form were cleared
of its old data after it was submitted, so that the user could immediately start entering the
next order. Resetting the form is as simple as calling the <form>
element’s reset method.
Find the FormHandler.prototype.addSubmitHandler
method
in formhandler.js. At the end of the
this.$formElement.on('submit'...)
callback,
add a call to the form’s reset method:
... FormHandler.prototype.addSubmitHandler = function (fn) { console.log('Setting submit handler for form'); this.$formElement.on('submit', function (event) { event.preventDefault(); var data = {}; $(this).serializeArray().forEach(function (item) { data[item.name] = item.value; console.log(item.name + ' is ' + item.value); ...
Get Front-End Web Development: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.