防止重复提交评论, 处理cloak元素

This commit is contained in:
yafeilee 2014-04-04 13:55:25 +08:00
parent febb325c76
commit f504116af9
3 changed files with 11 additions and 9 deletions

View File

@ -9,5 +9,5 @@
@app.config(["$httpProvider", (provider) ->
provider.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content')
provider.defaults.headers.common['Accept'] = 'application/json'
provider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
])

View File

@ -19,11 +19,13 @@
else
$scope.publish_success = false
$scope.publish_fail_msg = res.message
$timeout ->
$scope.publish_success = null
, 3*1000
.error ->
alert('xx')
.error (data, status)->
$scope.publish_success = false
$scope.publish_fail_msg = '网络错误, 请重试, 错误码为: ' + status
.finally ->
$scope.submitting = false
$scope.timeout = $timeout ->
$timeout.cancel($scope.timeout)
$scope.publish_success = null
, 5*1000
]

View File

@ -1,4 +1,4 @@
.row ng-controller="CommentsController"
.row ng-controller="CommentsController" ng-cloak=""
.small-12.large-9.large-centered.columns
form novalidate='' name='form'
.row
@ -8,10 +8,10 @@
.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 || submitting" 发表
button.comment-submit ng-click="submit()" ng-disabled="form.$invalid || submitting" {{ submitting && '发表中' || '发表' }}
p.comment-success ng-show="publish_success" 发布成功
p.comment-fail ng-show="publish_success == false" 发布失败: {{ publish_fail_msg }}
.comment-diag ng-cloak=""
.comment-diag
.comment-wrapper ng-repeat=" comment in comments "
p.name
|{{ comment.name + " • " }}