From 09dade0802ca97dffff0eff59d42d9413147e662 Mon Sep 17 00:00:00 2001 From: Rocky Duan Date: Sat, 1 Sep 2012 01:06:56 -0700 Subject: [PATCH] clear comment input after submit & not submit empty comment --- .../coffee/src/discussion/views/thread_response_view.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lms/static/coffee/src/discussion/views/thread_response_view.coffee b/lms/static/coffee/src/discussion/views/thread_response_view.coffee index dbe6a13111..5832018e46 100644 --- a/lms/static/coffee/src/discussion/views/thread_response_view.coffee +++ b/lms/static/coffee/src/discussion/views/thread_response_view.coffee @@ -57,12 +57,15 @@ class @ThreadResponseView extends Backbone.View if textStatus == 'success' @model.set(response) - submitComment: -> + submitComment: (event) -> url = @model.urlFor('reply') body = @$(".comment-form-input").val() + if not body.trim().length + return false comment = new Comment(body: body, created_at: (new Date()).toISOString(), username: window.user.get("username")) @renderComment(comment) @trigger "comment:add" + @$(".comment-form-input").val("") DiscussionUtil.safeAjax $elem: $(event.target) @@ -71,4 +74,5 @@ class @ThreadResponseView extends Backbone.View dataType: 'json' data: body: body + false