From febb325c76ae25c5f7684f3889b632126c8affc1 Mon Sep 17 00:00:00 2001 From: yafeilee Date: Fri, 4 Apr 2014 11:22:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=BF=E5=85=8D=E9=87=8D=E5=A4=8D=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/javascripts/angularjs/comments.js.coffee | 8 +++++--- app/views/blogs/_comment.html.slim | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/angularjs/comments.js.coffee b/app/assets/javascripts/angularjs/comments.js.coffee index ac90e03..9e134ff 100644 --- a/app/assets/javascripts/angularjs/comments.js.coffee +++ b/app/assets/javascripts/angularjs/comments.js.coffee @@ -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 ] diff --git a/app/views/blogs/_comment.html.slim b/app/views/blogs/_comment.html.slim index 9b828cf..b9a2eeb 100644 --- a/app/views/blogs/_comment.html.slim +++ b/app/views/blogs/_comment.html.slim @@ -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=""