Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by pepys on May 25, 2009 07:34
open dhtmlx forum
:: pepysDHTMLX :: dhtmlxFolders directly in BODY #2

Continuation for the thread: http://dhtmlx.com/docs/products/kb/index.shtml?cat=recent&q=9618

Actually, is not working.. :(

This is my code:

<body onLoad="doOnLoad()">


<script>


var myFolders;
function doOnLoad(){
    myFolders = new dhtmlxFolders("folders_container");
    myFolders.setItemType("fthumbs");
    myFolders.setUserData("thumbs_creator_url","./thumbs_creator.php?<?=$queryString;?>");
    myFolders.setUserData("photos_rel_dir", "../poze/<?=$tname?>/");
    myFolders.setUserData("icons_src_dir","<?=$dhtmlPath;?>dhtmlxFolders/samples/images");
    gridQString = "mygrid.php?<?=$queryString;?>";
    myFolders.loadXML(gridQString, "<?=$dhtmlPath;?>dhtmlxFolders/codebase/types/ficon.xsl");
   
    myFolders.setPagerContainer("pager");
    myFolders.enablePaging(6);
   
    //attach doOnClick function as onclick event handler
    function doOnDblClick(itemId){
        setStatus("dblclick. Item ID is "+itemId)
    }
    function doOnClick(itemId){
        setStatus("click. Item ID is "+itemId)
    }
    myFolders.attachEvent("onclick",doOnClick)
    myFolders.attachEvent("ondblclick",doOnDblClick)
}

function changeType(type){
    myFolders.setItemType(type, "<?=$dhtmlPath;?>dhtmlxFolders/codebase/types/"+type+".xsl");
}

function setStatus(str){
    document.getElementById("stat").innerHTML+=str+"<br>";
}
   
</script>
</body>



and I want to use it without onLoad="doOnLoad()" on body tag. How can I use your code

dhtmlxEvent("document.body","load",function(){
           ...any code here...
})

Can you show me please.. Thanks!
Answer posted by dhxSupport on May 25, 2009 07:50
In your code, you are using 
 myFolders = new dhtmlxFolders("folders_container");
so you need to have a container with such name, or replace it with 
 myFolders = new dhtmlxFolders(document.body);
if you want attach folders directly to the body

Sample attached
Attachments (1)
Answer posted on May 25, 2009 08:28

Answer posted by pepys on May 25, 2009 08:31
Sorry, I think you don't understand me. I don't want to have

<body onLoad="doOnLoad()">

but

<body>

I want this because I use the same html header in more files and I need onLoad="doOnLoad()" just for some files.
Answer posted by dhxSupport on May 25, 2009 10:17
Sorry, incorrect sample was attached to previous post. 
Please check this sample - it works without direct onload declaration
Attachments (1)
Answer posted by pepys on May 26, 2009 06:47
oh yes, now is really working, thanks a lot