loadContent:function()

in tapestry-framework/src/js/tapestry-4.1.6/core.js [242:310]


	loadContent:function(id, node, element){
        if (typeof element.childNodes != "undefined" && element.childNodes.length > 0) {
            for (var i = 0; i < element.childNodes.length; i++) {
                if (element.childNodes[i].nodeType != 1) { continue; }

                var nodeId = element.childNodes[i].getAttribute("id");
                if (nodeId) {
                    element=element.childNodes[i];
                    break;
                }
            }
        }

    	var content=tapestry.html.getContentAsString(element);
    	if (djConfig["isDebug"]) {
    		dojo.log.debug("Received element content for id <" + id + "> of: " + content);
    	}

        // on IE don't destroy event listeners on single element nodes like form input boxes/etc
        if (!tapestry.isIE || (tapestry.isIE && node.childNodes && node.childNodes.length > 0)){
            dojo.event.browser.clean(node); // prevent mem leaks in ie
        }

        // fix for IE - setting innerHTML does not work for SELECTs
        if (tapestry.isIE && !dj_undef("outerHTML", node) && node.nodeName == "SELECT") {
            node.outerHTML = node.outerHTML.replace(/(<SELECT[^<]*>).*(<\/SELECT>)/, '$1' + content + '$2');
            node=dojo.byId(id);
        } else if (content && content.length > 0
                && (!tapestry.isIE || content.length > 1)){
            node.innerHTML=content;
        }
        
        // copy attributes
		var atts=element.attributes;
		var attnode, i=0;
		while((attnode=atts[i++])){
            if(tapestry.isIE){
				if(!attnode){ continue; }
				if((typeof attnode == "object")&&
					(typeof attnode.nodeValue == 'undefined')||
					(attnode.nodeValue == null)||
					(attnode.nodeValue == '')){
					continue;
				}
			}

			var nn = attnode.nodeName;
			var nv = attnode.nodeValue;
			if (nn == "id" || nn == "type" || nn == "name"){continue;}

			if (nn == "style") {
				dojo.html.setStyleText(node, nv);
			} else if (nn == "class") {
				dojo.html.setClass(node, nv);
			} else if (nn == "value") {
                node.value = nv;
            } else {
				node.setAttribute(nn, nv);
			}
        }

    	// apply disabled/not disabled
    	var disabled = element.getAttribute("disabled");
        if (!disabled && node["disabled"]) {
            node.disabled = false;
        } else if (disabled) {
    		node.disabled = true;
        }
	},