diff --git a/app/assets/javascripts/comments.js.erb b/app/assets/javascripts/comments.js.erb index b1a694f26..8b8e0037b 100644 --- a/app/assets/javascripts/comments.js.erb +++ b/app/assets/javascripts/comments.js.erb @@ -22,7 +22,6 @@ var Comments = (function() { beforeSend: animateSpinner(that, true) }) .done(function(data) { that.html(data.html); - }) .always(function() { animateSpinner(that, false); @@ -51,7 +50,7 @@ var Comments = (function() { // Initialize show more comments link. function initCommentsLink($el) { - $el.find('.btn-more-comments') + $el.find('.btn-more-comments').off() .on('ajax:success', function (e, data) { if (data.html) { var list = $(this).parents('ul'); @@ -92,7 +91,7 @@ var Comments = (function() { $('.help-block', $form).addClass('hide'); - $form.on('ajax:send', function () { + $form.off().on('ajax:send', function () { $('#comment_message', $form).attr('readonly', true); }) .on('ajax:success', function (e, data) { @@ -164,33 +163,6 @@ var Comments = (function() { }); } - // restore comments after update or when new element is created - function bindCommentInitializerToNewElement() { - if( document.getElementById('steps') !== null ) { - $('#steps') - .change(function() { - $('.step-save') - .on('click', function() { - $(document) - .on('ajax:success', function(){ - initializeComments(); - }); - }); - }); - } else if ( document.getElementById('results') !== null ) { - $('#results') - .change(function() { - $('.save-result') - .on('click', function() { - $(document) - .on('ajax:success', function(){ - initializeComments(); - }); - }); - }); - } - } - function initCommentOptions(scrollableContainer, useParentOffset) { if ( ! _.isUndefined(useParentOffset) ) { useParentOffset = useParentOffset; @@ -377,7 +349,6 @@ var Comments = (function() { scrollBottom: scrollBottom, moreComments: initCommentsLink, form: initCommentForm, - bindNewElement: bindCommentInitializerToNewElement, initCommentOptions: initCommentOptions, initDeleteComments: initDeleteComments, initEditComments: initEditComments diff --git a/app/assets/javascripts/my_modules/protocols.js.erb b/app/assets/javascripts/my_modules/protocols.js.erb index 5c83fcce6..eacd54506 100644 --- a/app/assets/javascripts/my_modules/protocols.js.erb +++ b/app/assets/javascripts/my_modules/protocols.js.erb @@ -16,7 +16,6 @@ function init() { initLoadFromRepository(); initRefreshStatusBar(); initImport(); - Comments.bindNewElement(); setupAssetsLoading(); } diff --git a/app/assets/javascripts/my_modules/results.js.erb b/app/assets/javascripts/my_modules/results.js.erb index 57f7d5bc3..f64a696c1 100644 --- a/app/assets/javascripts/my_modules/results.js.erb +++ b/app/assets/javascripts/my_modules/results.js.erb @@ -17,7 +17,6 @@ _expandAllResults(); applyCollapseLinkCallBack(); - Comments.bindNewElement(); Comments.initialize(); Comments.initCommentOptions('ul.content-comments');