Index: lams_central/web/includes/javascript/rating.js =================================================================== diff -u -refa71ab50f03a96f694b0d19a3ea1a1a64c3bdcb -ra7677ac542ba178120ae80ad9f2c6878f46846d5 --- lams_central/web/includes/javascript/rating.js (.../rating.js) (revision efa71ab50f03a96f694b0d19a3ea1a1a64c3bdcb) +++ lams_central/web/includes/javascript/rating.js (.../rating.js) (revision a7677ac542ba178120ae80ad9f2c6878f46846d5) @@ -130,48 +130,53 @@ toolSessionId: SESSION_ID }, success: function(data, textStatus) { - if ( data.error ) { + if (data.error) { handleError(); - } else { - var commentsArea = $('#comments-area-' + itemId); - - if (data.allComments) { - // add all users' comments to HTML - jQuery.each(data.allComments, function(){ - jQuery('
', { - 'class': "rating-comment", - html: this - }).appendTo(commentsArea); - }); - } else { - //add this user's comment to HTML + return; + } + + debugger; + // LDEV-4480 Acknowledgement when submitting a comment for a Q&A response + alert("Submitted the comment successfully."); + + if (refreshOnSubmit) { + // LDEV-5052 Refresh page and scroll to the given ID on comment submit + var url = location.href, + anchorIndex = url.lastIndexOf('#'); + if (anchorIndex > 0) { + url = url.substring(0, anchorIndex); + } + url += '#' + refreshOnSubmit; + location.href = url; + return; + } + + + var commentsArea = $('#comments-area-' + itemId); + + if (data.allComments) { + // add all users' comments to HTML + jQuery.each(data.allComments, function(){ jQuery('', { 'class': "rating-comment", - html: data.comment + html: this }).appendTo(commentsArea); - } - - //hide comments textarea and button - $("#add-comment-area-" + itemId, commentsArea).hide(); - - //handle rating limits if available - if (HAS_RATING_LIMITS) { - handleRatingLimits(data.countRatedItems, itemId); - } - //LDEV-4480 Acknowledgement when submitting a comment for a Q&A response - alert("Submitted the comment successfully."); - - // LDEV-5052 Refresh page and scroll to comments on submit - if (refreshOnSubmit) { - var url = location.href, - anchorIndex = url.lastIndexOf('#'); - if (anchorIndex > 0) { - url = url.substring(0, anchorIndex); - } - url += '#comments-area-' + itemId; - location.href = url; - } - } + }); + } else { + //add this user's comment to HTML + jQuery('', { + 'class': "rating-comment", + html: data.comment + }).appendTo(commentsArea); + } + + //hide comments textarea and button + $("#add-comment-area-" + itemId, commentsArea).hide(); + + //handle rating limits if available + if (HAS_RATING_LIMITS) { + handleRatingLimits(data.countRatedItems, itemId); + } }, onError : function(){ handleError();