From 0f3db8a644fae7ee39f952dcb10726f5ffd5e454 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Wed, 16 Aug 2017 17:29:08 +0200 Subject: [PATCH] Remove old comments before refresh to fix event leak --- app/views/request_for_comments/show.html.erb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/views/request_for_comments/show.html.erb b/app/views/request_for_comments/show.html.erb index ce6f8d8e..3e889ac6 100644 --- a/app/views/request_for_comments/show.html.erb +++ b/app/views/request_for_comments/show.html.erb @@ -140,6 +140,11 @@ also, all settings from the rails model needed for the editor configuration in t currentEditor.on("guttermousedown", handleSidebarClick); }); + function cleanupPopovers() { + // remove all possible popovers + $('.editor > .ace_gutter > .ace_gutter-layer > .ace_gutter-cell').popover('destroy'); + } + function setAnnotations(editor, fileid) { var session = editor.getSession(); @@ -166,7 +171,7 @@ also, all settings from the rails model needed for the editor configuration in t cluster.forEach(function(comment) { popupContent += '

' + comment.username + ': ' + comment.text.replace(/\n/g, '
') + '

'; }); - var icon = $('*[data-file-id="' + fileid + '"] > .ace_gutter > .ace_gutter-layer > .ace_gutter-cell:contains("' + (clusterRow + 1) + '")'); + var icon = $('*[data-file-id="' + fileid + '"] > .ace_gutter > .ace_gutter-layer > div:nth-child(' + (clusterRow + 1) + ')'); icon.popover({ content: popupContent, html: true, @@ -201,6 +206,7 @@ also, all settings from the rails model needed for the editor configuration in t } function deleteComment(file_id, row, editor) { + cleanupPopovers(); var jqxhr = $.ajax({ type: 'DELETE', url: "/comments", @@ -215,6 +221,7 @@ also, all settings from the rails model needed for the editor configuration in t } function createComment(file_id, row, editor, commenttext){ + cleanupPopovers(); var jqxhr = $.ajax({ data: { comment: {