Show More
@@ -36,6 +36,7 b' var ALLOWED_FOR_PARTIAL_UPDATE = [' | |||||
36 | ]; |
|
36 | ]; | |
37 |
|
37 | |||
38 | var ATTR_CLASS = 'class'; |
|
38 | var ATTR_CLASS = 'class'; | |
|
39 | var ATTR_UID = 'data-uid'; | |||
39 |
|
40 | |||
40 | var wsUser = ''; |
|
41 | var wsUser = ''; | |
41 |
|
42 | |||
@@ -372,12 +373,9 b' function processNewPost(post) {' | |||||
372 |
|
373 | |||
373 | function replacePartial(oldNode, newNode, recursive) { |
|
374 | function replacePartial(oldNode, newNode, recursive) { | |
374 | if (!equalNodes(oldNode, newNode)) { |
|
375 | if (!equalNodes(oldNode, newNode)) { | |
375 |
// Update parent node |
|
376 | // Update parent node attributes | |
376 | var oldClass = oldNode.attr(ATTR_CLASS); |
|
377 | updateNodeAttr(oldNode, newNode, ATTR_CLASS); | |
377 | var newClass = newNode.attr(ATTR_CLASS); |
|
378 | updateNodeAttr(oldNode, newNode, ATTR_UID); | |
378 | if (oldClass != newClass) { |
|
|||
379 | oldNode.attr(ATTR_CLASS, newClass); |
|
|||
380 | }; |
|
|||
381 |
|
379 | |||
382 | // Replace children |
|
380 | // Replace children | |
383 | var children = oldNode.children(); |
|
381 | var children = oldNode.children(); | |
@@ -420,6 +418,17 b' function equalNodes(node1, node2) {' | |||||
420 | return node1[0].outerHTML == node2[0].outerHTML; |
|
418 | return node1[0].outerHTML == node2[0].outerHTML; | |
421 | } |
|
419 | } | |
422 |
|
420 | |||
|
421 | /** | |||
|
422 | * Update attribute of a node if it has changed | |||
|
423 | */ | |||
|
424 | function updateNodeAttr(oldNode, newNode, attrName) { | |||
|
425 | var oldAttr = oldNode.attr(attrName); | |||
|
426 | var newAttr = newNode.attr(attrName); | |||
|
427 | if (oldAttr != newAttr) { | |||
|
428 | oldNode.attr(attrName, newAttr); | |||
|
429 | }; | |||
|
430 | } | |||
|
431 | ||||
423 | $(document).ready(function(){ |
|
432 | $(document).ready(function(){ | |
424 | if (initAutoupdate()) { |
|
433 | if (initAutoupdate()) { | |
425 | // Post form data over AJAX |
|
434 | // Post form data over AJAX |
General Comments 0
You need to be logged in to leave comments.
Login now