Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
help on yui tree menu
Old 08-29-2007, 08:18 AM help on yui tree menu
Skilled Talker

Posts: 70
Name: rex
Trades: 0
hi guys,

my question is regarding yui tree menu. im a newbie and trying to take advantage of this rich library. my worry is about removeNode() or how to remove or delete a node on real-time.

i have a code that contains a button and when the user push this button it will create a node on real-time. and my code goes like this:

function addbtn(){
g=prompt('New Node Name: ','');
if(g.length>0){
e=g;
e=new YAHOO.widget.TextNode(g,mytree.getRoot(),false);
mytree.draw();
}
}

i think i'm ok with it, works well for now and does the trick. now if i want to remove that recent node my code goes like this:

function rembtn(){
p=prompt('What Node to remove:','');
if(p.length>0){
mytree.removeNode(eval(p),true);
mytree.draw();
}
}

for instance i added a node "games". now upon removing, if type "games" it will give me an error. but if i type "e", which is the variable name when i created a node from addbtn() it runs successfully. can someone pls tell me the work around for my issue?

tnx
shotokan99 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-31-2007, 05:40 PM Re: help on yui tree menu
Skilled Talker

Posts: 62
Name: Tom Wright
Location: Brighton, UK
Trades: 0
Disclaimer: I've never worked with yui before.
I've noticed two issues with the above code - one a potential pitfall.
First the non-critical: the line e=g; is completely superfluous as you immediately redefine e and proceed to reference g as itself.
Second (and more importantly): I'm not entirely sure why you've opted to evaluate p on the penultimate line of rembtn. I'm not sure if this would cause the behavior you describe, but it'd be where I'd start.
Hope this helps, Tom.
__________________
My site:
Please login or register to view this content. Registration is FREE
tomythius is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to help on yui tree menu
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.39065 seconds with 12 queries