diff --git a/app/assets/javascripts/angularjs.js.coffee b/app/assets/javascripts/angularjs.js.coffee index 4118e69..8e95b06 100644 --- a/app/assets/javascripts/angularjs.js.coffee +++ b/app/assets/javascripts/angularjs.js.coffee @@ -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' ]) diff --git a/app/assets/javascripts/angularjs/comments.js.coffee b/app/assets/javascripts/angularjs/comments.js.coffee index 9e134ff..ce78b8b 100644 --- a/app/assets/javascripts/angularjs/comments.js.coffee +++ b/app/assets/javascripts/angularjs/comments.js.coffee @@ -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 ] diff --git a/app/views/blogs/_comment.html.slim b/app/views/blogs/_comment.html.slim index b9a2eeb..8df20d5 100644 --- a/app/views/blogs/_comment.html.slim +++ b/app/views/blogs/_comment.html.slim @@ -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 + " • " }}