Advertisement

What's wrong with my code

Moderators: Calcifer, slothy

What's wrong with my code

Postby sendman » Thu Sep 28, 2006 3:22 pm

Hi all.

I have this lines on my tree html:

=cut
<li nodrag="false" nosiblings="true" class="folder" id="7"><a onclick="load_category('7')">cat7</a> <a onclick="remove_item('7')">remove</a>
<ul id="ul7"></li>

<li nodrag="false" nosiblings="true" class="folder" id="15"><a onclick="load_category('15')">cat15</a> <a onclick="remove_item('15')">remove</a>
<ul id="ul15"></li>
</ul>

<li nodrag="false" nosiblings="true" class="folder" id="18"><a onclick="load_category('18')">cat18</a> <a onclick="remove_item('18')">remove</a>
<ul id="ul18"></li>

<li nodrag="false" nosiblings="true" class="folder" id="93"><a onclick="load_category('93')">cat93</a> <a onclick="remove_item('93')">remove</a>
<ul id="ul93"></li>
</ul>
</ul>

=cut

And this is the load_category function in javascript file:

function load_category(id)
{
saveString = treeObj.getNodeOrders();
var ajaxIndex = ajaxObjects.length;
ajaxObjects[ajaxIndex] = new sack();
var url = '?mode=cat&category='+id;
ajaxObjects[ajaxIndex].requestFile = url; // Specifying which file to get
ajaxObjects[ajaxIndex].method = 'GET';
ajaxObjects[ajaxIndex].onCompletion = function() { showCategory(ajaxIndex,id
); } ; // Specify function that will be executed after file has been found
ajaxObjects[ajaxIndex].runAJAX(); // Execute AJAX function
}

And the showCategory function:

function showCategory(ajaxIndex,id) {
var e = document.getElementById('ul'+id);
var li = e.createElement('LI'); // Create new <li> tag.
var aTag = e.createElement('A'); // Creating <a> tag
aTag.innerHTML = 'Name of new node'; // Text of a tag
aTag.href='#';
li.appendChild(a);
e.appendChild(li);
}

So when user click on load_category, I want to add some item (<li> tag with <a href>) on the respective parent.

Why this don't work, if I create the <ul id=x> outsite the tree, the elementes are created, but with the ul inside the tree dont work.

Regards.
sendman
 
Posts: 2
Joined: Thu Sep 14, 2006 8:26 pm

Return to Folder tree questions

Who is online

Users browsing this forum: No registered users and 2 guests

cron