# HG changeset patch # User neko259 # Date 2015-08-27 09:55:30 # Node ID 872ff2a976d9a754cac86ff88f4028d857122635 # Parent d6b6426d74d78448b273a88718cc55f8767d6442 Update post's uid too diff --git a/boards/static/js/thread_update.js b/boards/static/js/thread_update.js --- a/boards/static/js/thread_update.js +++ b/boards/static/js/thread_update.js @@ -36,6 +36,7 @@ var ALLOWED_FOR_PARTIAL_UPDATE = [ ]; var ATTR_CLASS = 'class'; +var ATTR_UID = 'data-uid'; var wsUser = ''; @@ -372,12 +373,9 @@ function processNewPost(post) { function replacePartial(oldNode, newNode, recursive) { if (!equalNodes(oldNode, newNode)) { - // Update parent node class attribute - var oldClass = oldNode.attr(ATTR_CLASS); - var newClass = newNode.attr(ATTR_CLASS); - if (oldClass != newClass) { - oldNode.attr(ATTR_CLASS, newClass); - }; + // Update parent node attributes + updateNodeAttr(oldNode, newNode, ATTR_CLASS); + updateNodeAttr(oldNode, newNode, ATTR_UID); // Replace children var children = oldNode.children(); @@ -420,6 +418,17 @@ function equalNodes(node1, node2) { return node1[0].outerHTML == node2[0].outerHTML; } +/** + * Update attribute of a node if it has changed + */ +function updateNodeAttr(oldNode, newNode, attrName) { + var oldAttr = oldNode.attr(attrName); + var newAttr = newNode.attr(attrName); + if (oldAttr != newAttr) { + oldNode.attr(attrName, newAttr); + }; +} + $(document).ready(function(){ if (initAutoupdate()) { // Post form data over AJAX