防止重复提交评论, 处理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) -> @app.config(["$httpProvider", (provider) ->
provider.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content') 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 else
$scope.publish_success = false $scope.publish_success = false
$scope.publish_fail_msg = res.message $scope.publish_fail_msg = res.message
$timeout -> .error (data, status)->
$scope.publish_success = null $scope.publish_success = false
, 3*1000 $scope.publish_fail_msg = '网络错误, 请重试, 错误码为: ' + status
.error ->
alert('xx')
.finally -> .finally ->
$scope.submitting = false $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 .small-12.large-9.large-centered.columns
form novalidate='' name='form' form novalidate='' name='form'
.row .row
@ -8,10 +8,10 @@
.small-12.large-6.columns .small-12.large-6.columns
= text_field_tag(:name, nil, placeholder: '你的名字', 'ng-model'=> 'name', 'ng-required'=> 'true') = 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") = 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-success ng-show="publish_success" 发布成功
p.comment-fail ng-show="publish_success == false" 发布失败: {{ publish_fail_msg }} p.comment-fail ng-show="publish_success == false" 发布失败: {{ publish_fail_msg }}
.comment-diag ng-cloak="" .comment-diag
.comment-wrapper ng-repeat=" comment in comments " .comment-wrapper ng-repeat=" comment in comments "
p.name p.name
|{{ comment.name + " • " }} |{{ comment.name + " • " }}