Components that render as multiple dom nodes (e.g. more that one element,
leading spaces/text, etc.) do not get replaced properly.
For example, trying to replace the first link in a form replaces the link with
"\n\n" (since the link rendered as "<script.../script>\n\n<a href=..." and the
script element is stripped out).
Workaround/Patch (also contains workaround for issue 69):
function safeReplace(id,markup) {
var str = markup.stripScripts();
if( str.strip().length !== 0 ) {
if (-1 === id.indexOf(DynaFaces.gViewRoot)) {
var d = DynaFaces.$(id);
if(!d)
{ alert('Could not find '+id); }
var parent = d.parentNode;
var temp = document.createElement("div");
temp.id = d.id;
temp.innerHTML = str;
// replace the element with all of temp's children
// (might be extra text nodes or something)
var last = parent.replaceChild(temp.lastChild, d);
for(var i = 1; i < temp.childNodes.length; i++)
{ parent.insertBefore( temp.childNodes[i], last ); }
Components that render as multiple dom nodes (e.g. more that one element, leading spaces/text, etc.) do not get replaced properly.
For example, trying to replace the first link in a form replaces the link with "\n\n" (since the link rendered as "<script.../script>\n\n<a href=..." and the script element is stripped out).
Workaround/Patch (also contains workaround for issue 69):
DynaFaces.fireAjaxTransaction( component, { ... replaceElement: safeReplace } );
function safeReplace(id,markup) { var str = markup.stripScripts(); if( str.strip().length !== 0 ) { if (-1 === id.indexOf(DynaFaces.gViewRoot)) { var d = DynaFaces.$(id); if(!d)
{ alert('Could not find '+id); }
var parent = d.parentNode; var temp = document.createElement("div"); temp.id = d.id; temp.innerHTML = str;
// replace the element with all of temp's children // (might be extra text nodes or something) var last = parent.replaceChild(temp.lastChild, d); for(var i = 1; i < temp.childNodes.length; i++)
{ parent.insertBefore( temp.childNodes[i], last ); }
} else
{ DynaFaces.replace(id,str); }
} }
Environment
Operating System: All Platform: All
Affected Versions
[current]