Skip to content

Instantly share code, notes, and snippets.

@drale2k
Created March 19, 2012 16:20
Show Gist options
  • Save drale2k/2117874 to your computer and use it in GitHub Desktop.
Save drale2k/2117874 to your computer and use it in GitHub Desktop.
createDevice: (e) ->
event.preventDefault()
attributes =
licence_plate: $(@el).find('input[name="licence-plate"]').val()
contact_name: $(@el).find('input[name="contact-name"]').val()
contact_phone: $(@el).find('input[name="contact-phone"]').val()
@collection.create attributes,
wait: true
success: -> alert "hi"
error: ->
alert "hi"
handleError: (entry, response) ->
if response.status == 422
errors = $.parseJSON(response.responseText).errors
for attribute, messages of errors
alert "#{attribute} #{message}" for message in messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment