Last active
August 29, 2015 13:57
-
-
Save digilord/9491860 to your computer and use it in GitHub Desktop.
Simple form getter.
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
_data = {} | |
_inputElements = ['input', 'select', 'textarea'] | |
# Find this templates 'form' | |
form = template.find('form'); | |
for type in _inputElements | |
# Get all the fields as an array of jQuery objects | |
elements = $(form).find(type) | |
for element in elements | |
console.log element | |
if element.type == 'checkbox' | |
_data[element.name] = $(element).prop('checked') | |
else | |
_data[element.name] = element.value | |
console.log _data | |
# At this point you should have an object fit for inserting | |
# into a Meteor collection. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment