From 8d7285ce7ccbff2c4fbb9754ceeb85b5ca79da5a Mon Sep 17 00:00:00 2001 From: zmagod Date: Tue, 22 Nov 2016 14:39:08 +0100 Subject: [PATCH] load comments after edit step [fixes SCI-716] --- app/assets/javascripts/protocols/steps.js.erb | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/protocols/steps.js.erb b/app/assets/javascripts/protocols/steps.js.erb index cf6760309..9dbb8b598 100644 --- a/app/assets/javascripts/protocols/steps.js.erb +++ b/app/assets/javascripts/protocols/steps.js.erb @@ -77,6 +77,11 @@ function applyCancelCallBack() { initCallBacks(); initHandsOnTable($new_step); toggleButtons(true); + + setTimeout(function() { + initStepsComments(); + }, 1000); + }) .on("ajax:error", function(e, xhr, status, error) { // TODO: error handling @@ -173,6 +178,10 @@ function formCallback($form) { contents.attr("value", data); } }); + + setTimeout(function() { + initStepsComments(); + }, 1000); return true; }); } @@ -545,17 +554,20 @@ function renderTable(table) { } } +function initStepsComments() { + Comments.initialize(); + Comments.initCommentOptions("ul.content-comments"); + Comments.initEditComments("#steps"); + Comments.initDeleteComments("#steps"); +} + $(document).ready(function() { // On init initCallBacks(); initHandsOnTable($(document)); expandAllSteps(); setupAssetsLoading(); - - // Init comments edit/delete - Comments.initCommentOptions("ul.content-comments"); - Comments.initEditComments("#steps"); - Comments.initDeleteComments("#steps"); + initStepsComments(); $(function () {