避免重复提交回复

This commit is contained in:
yafeilee 2014-04-04 11:22:00 +08:00
parent 99e8125952
commit febb325c76
2 changed files with 6 additions and 4 deletions

View File

@ -8,6 +8,7 @@
$scope.publish_success = null
$scope.submit = ->
$scope.submitting = true
comment = { content: $scope.content, name: $scope.name, email: $scope.email }
$http.post(url, comment)
.success (res)->
@ -21,7 +22,8 @@
$timeout ->
$scope.publish_success = null
, 3*1000
.error (data)->
alert(data)
.error ->
alert('xx')
.finally ->
$scope.submitting = false
]

View File

@ -8,7 +8,7 @@
.small-12.large-6.columns
= text_field_tag(:name, nil, placeholder: '你的名字', 'ng-model'=> 'name', 'ng-required'=> 'true')
= text_field_tag(:email, nil, placeholder: '你的邮箱', 'ng-model'=> 'email', 'ng-pattern'=>"/^.+@.+$/", 'ng-required'=>"true")
button.comment-submit ng-click="submit()" ng-disabled="form.$invalid" 发表
button.comment-submit ng-click="submit()" ng-disabled="form.$invalid || submitting" 发表
p.comment-success ng-show="publish_success" 发布成功
p.comment-fail ng-show="publish_success == false" 发布失败: {{ publish_fail_msg }}
.comment-diag ng-cloak=""