Skip to content

Instantly share code, notes, and snippets.

@digilord
Last active August 29, 2015 13:57
Show Gist options
  • Save digilord/9491860 to your computer and use it in GitHub Desktop.
Save digilord/9491860 to your computer and use it in GitHub Desktop.
Simple form getter.
_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