swapDOM does not in point of fact swap elements, just replaces them. I
find it stange that the return value is the overwiting element, not the
overwriten one.
Anyhow, I wrote my own swapElements function which saves the
overwritten element for use again, so swapping table rows and
re-ordering is nice and easy:
function swapElements(elem1, elem2) {
if(typeof(elem1) == "string") {
elem1 = getElement(elem1);
}
if(typeof(elem2) == "string") {
elem2 = getElement(elem2);
}
placer1 = DIV();
placer2 = DIV();
parent1 = elem1.parentNode;
parent2 = elem2.parentNode;
//DOM Func: replacedNode = parentNode.replaceChild(newChild,
oldChild);
e_old = parent1.replaceChild(placer1, elem1);
e_new = parent2.replaceChild(placer2, elem2);
swapDOM(placer1, e_new);
swapDOM(placer2, e_old);
}
this is fine for IE and FFox, not sure if it fits in totally with
Mochikit, but it would be nice to see something like this implemented
into Mochi, as truly swapping elements is desired regularly by many of
us..
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---