I have some jquery code which I am trying to translate to YUI. I am using YUI 2.8. Using jquery I could have easily replaced a dom element. Is there a good way to use YUI in place of jquery.replaceWith and jquery.append. I tried writing my functions as below, but these can only take text, while I need to pass a rendered dom like. <p><a href="">what</a></p>
(much more complex than this.)
function replaceWith(el_id, text){
//YUI doesn't seem to have a good replacement for $.replaceWith. Writing one to simulate it for my usages.
node_to_replace = YAHOO.util.Dom.get(el_id);
if(node_to_replace){
new_node = document.createTextNode(text);
YAHOO.util.Dom.insertAfter(new_node, node_to_replace);
node_to_replace.innerHTML = ''
}
return node_to_replace
}
function append(el_id, text){
//YUI doesn't seem to have a good replacement for $.append. Writing one to simulate it for my usages.
node_to_replace = YAHOO.util.Dom.get(el_id);
if(node_to_replace){
new_node = document.createTextNode(text);
YAHOO.util.Dom.insertAfter(new_node, node_to_replace);
}
return node_to_replace
}