Sha256: 1cc852fecd57b37f5020bcb21f581251f209e87c10d35bee976fc13a29ee69db

Contents?: true

Size: 734 Bytes

Versions: 1

Compression:

Stored size: 734 Bytes

Contents

require "lib/jquery"

Signal = require "cronus/signal"

#
# @author - Tim Shelburne <tim@musiconelive.com>
#
# handles submitting a form and waiting for a response
#
class SimpleSubmitter
  constructor: ->
    @submittedWithSuccess = new Signal()
    @submittedWithError = new Signal()

  canSubmit: (form)-> form.type is "simple"

  submitForm: (form)->
    $.ajax
      url: form.action
      type: form.method
      data: form.serialize()
      success: (data)=>
        @submitSuccess(form, data)
      error: (xhr, text)=> @submitError(form, xhr, text)

  submitSuccess: (form, data)-> @submittedWithSuccess.dispatch(form, data)

  submitError: (form, xhr, text)-> @submittedWithError.dispatch(form, text)

return SimpleSubmitter

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hoarder-js-0.0.1 assets/scripts/coffee/hoarder/submitter/submitters/simple_submitter.coffee