From 67536d5ca575954ed90b72f473ff57df866d57cf Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Fri, 16 Sep 2016 01:05:32 +0200 Subject: [PATCH] Fix JS to replace liveblog plugin --- djangocms_blog/liveblog/static/liveblog/js/liveblog.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/djangocms_blog/liveblog/static/liveblog/js/liveblog.js b/djangocms_blog/liveblog/static/liveblog/js/liveblog.js index 3f7ff3a..5042498 100644 --- a/djangocms_blog/liveblog/static/liveblog/js/liveblog.js +++ b/djangocms_blog/liveblog/static/liveblog/js/liveblog.js @@ -9,11 +9,11 @@ document.addEventListener("DOMContentLoaded", function() { var data = JSON.parse(message.data); // See if there's a div to replace it in, or if we should add a new one var existing = document.querySelectorAll("div[data-post-id*='" + data.id + "']"); - if (existing.length) { - existing.parentNode.replaceChild(data.content, existing); + var item = document.createElement('div'); + item.innerHTML = data.content; + if (existing.length > 0) { + existing[0].parentNode.replaceChild(item.children[0], existing[0]); } else { - var item = document.createElement('div'); - item.innerHTML = data.content; document.getElementById("liveblog-posts").insertBefore( item.children[0], document.getElementById("liveblog-posts").children[0] );