-
-
-
+ var theForm = $(newForm);
+ disableButton(btnName);
-
-
+ if (validateBodyText(
+ $('#newFormBody').val(),
+ <%=CommentConstants.MAX_BODY_LENGTH%>,
+ "
"
+ )) {
+ $.ajax({ // create an AJAX call...
+ data : theForm.serialize(),
+ processData : false, // tell jQuery not to process the data
+ contentType : false, // tell jQuery not to set contentType
+ type : theForm.attr('method'), // GET or POST
+ url : theForm.attr('action'), // the file to call
+
+ }).done(function(response) {
+ var threadUid = response.threadUid;
+ var commentUid = response.commentUid;
+ var sessionMapID = response.sessionMapID;
-
+ // have just added it as a standalone comment, so show the posting at the top.
+ var newCommentDiv = document.getElementById('newcomments');
+ var newThreadDiv = document.createElement("div");
+ newThreadDiv.id = 'thread' + commentUid;
+ newCommentDiv.insertBefore(newThreadDiv, newCommentDiv.firstChild);
+
+ if (!newCommentDiv || !newThreadDiv) {
+ alert('
');
+ } else if (commentUid) {
+ var loadString = '
comments/viewTopicThread.do?sessionMapID='
+ + response.sessionMapID
+ + "&threadUid="
+ + threadUid
+ + "&commentUid=" + commentUid;
+ $.ajaxSetup({ cache: true });
+ $(newThreadDiv).load(loadString,
+ function() {
+ highlightMessage();
+ });
+ clearNewForm();
+ } else if (response.errMessage) {
+ alert(response.errMessage);
+ enableButton(btnName);
+ } else {
+ alert('
');
+ }
+ });
+ } // end validateBodyText
+ else {
+ enableButton(btnName);
+ }
+ return false;
+ }
+
+ function clearNewForm() {
+ $('#newFormBody').val('');
+ $('#commentAnonymousNew').prop('checked',false);
+ enableButton(btnName);
+ return false;
+ }
+
+
+
+
+
+
+
\ No newline at end of file