Skip to content

Commit

Permalink
Disable button and change text while loading.
Browse files Browse the repository at this point in the history
  • Loading branch information
tremulaes committed Apr 20, 2015
1 parent 38eb1af commit df1bc05
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ class App.Views.Users.Edit extends App.View
render: ->
@$el.html(@template(@model.attributes))
onFormSubmit: ->
$('#get_api').attr('disabled', true)
$('#get_api').val('Loading...')
form = @$el.find "form"
newAttrs = @updateModelFromForm(form)
success = =>
gh_handle = @model.get('github_handle')
window.getGitHubData(gh_handle) if gh_handle
App.router.navigate("/#{@model.get('username')}", {trigger: true});
error = -> $('.message').html("<span class='error'>There was an issue saving your updates</span>")
error = ->
$('#get_api').attr('disabled', false)
$('#get_api').val('Submit')
$('.message').html("<span class='error'>There was an issue saving your updates</span>")
@model.save(newAttrs, success: success, error: error)
false

Expand Down

0 comments on commit df1bc05

Please sign in to comment.