Search the web
Sign In
New User? Sign Up
ydn-javascript · Yahoo! User Interface Library Group
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
MenuButton - how to get value of the selected item   Message List  
Reply | Forward Message #43410 of 52125 |
RE: [ydn-javascript] MenuButton - how to get value of the selected item

I am not familiar with the value property,
 
but for example in my app I have:
 
{ text: "One", onclick: { fn: onMenuItemClick, obj: "1" } },
 
Then
 
I can get the value: 1
 
function onMenuItemClick(p_sType, p_aArgs, p_oValue) {
     dashboard_id = p_oValue;
}
 
I hope that help you.
 


From: ydn-javascript@yahoogroups.com [mailto:ydn-javascript@yahoogroups.com] On Behalf Of Pawel Sokolowski
Sent: Wednesday, January 07, 2009 12:14 PM
To: ydn-javascript@yahoogroups.com
Subject: Re: [ydn-javascript] MenuButton - how to get value of the selected item

     var projectName = this.cfg.getProperty("text");
only gets the value of the property text not the value of the property value


I need to grab the value of the property value so that :
 { text: "one", value: 1, onclick: { fn: onMenuItemClick } },
{ text: "two", value: 2, onclick: { fn: onMenuItemClick } },
{ text: "three", value: 3, onclick: { fn: onMenuItemClick } }
when "one" is clicked i can read value which is == 1. 
is there a way to access this property ?
Thanks, 

Pawel 
On Wed, Jan 7, 2009 at 2:54 PM, a Eric Daniel Leon Gonzalez <gonzalez@pv.com> wrote:

function onMenuItemClick(p_sType, p_aArgs, p_oValue) {
     // Set project title
     var projectName = this.cfg.getProperty("text");
}
 
Does that help?


From: ydn-javascript@yahoogroups.com [mailto:ydn-javascript@yahoogroups.com] On Behalf Of Pawel Sokolowski
Sent: Wednesday, January 07, 2009 11:29 AM
To: ydn-javascript@yahoogroups.com
Subject: [ydn-javascript] MenuButton - how to get value of the selected item

Hello, 


Is there way to retrieve a value of the selected item in the event handler "onMenuItemClick" ? Please see the code below that was taken from the examples at YUI page. 
// "click" event handler for each item in the Button's menu
function onMenuItemClick(p_sType, p_aArgs, p_oItem) {
oMenuButton4.set("label", p_oItem.cfg.getProperty("text"));
 // there is no property value in the config object 
 alert(p_oItem.cfg.getProperty("value"));
}
// Create an array of YAHOO.widget.MenuItem configuration properties
var aMenuButton4Menu = [
{ text: "one", value: 1, onclick: { fn: onMenuItemClick } },
{ text: "two", value: 2, onclick: { fn: onMenuItemClick } },
{ text: "three", value: 3, onclick: { fn: onMenuItemClick } }
];
/*
Instantiate a Menu Button using the array of YAHOO.widget.MenuItem configuration properties as the value for the "menu" configuration attribute.
*/
var oMenuButton4 = new YAHOO.widget.Button({ type: "menu", label: "one", name: "mymenubutton",
menu: aMenuButton4Menu, container: "menubuttonsfromjavascript" }); 




Wed Jan 7, 2009 8:30 pm

gonzalez@...
Send Email Send Email

Forward
Message #43410 of 52125 |
Expand Messages Author Sort by Date

Hello, Is there way to retrieve a value of the selected item in the event handler " onMenuItemClick" ? Please see the code below that was taken from the ...
Pawel Sokolowski
psokolo
Offline Send Email
Jan 7, 2009
7:28 pm

function onMenuItemClick(p_sType, p_aArgs, p_oValue) { // Set project title var projectName = this.cfg.getProperty("text"); } Does that help? ...
a Eric Daniel Leon Go...
gonzalez@...
Send Email
Jan 7, 2009
7:54 pm

var projectName = this.cfg.getProperty("text"); only gets the value of the property text not the value of the property value I need to grab the value of the...
Pawel Sokolowski
psokolo
Offline Send Email
Jan 7, 2009
8:14 pm

I am not familiar with the value property, but for example in my app I have: { text: "One", onclick: { fn: onMenuItemClick, obj: "1" } }, Then I can get the...
a Eric Daniel Leon Go...
gonzalez@...
Send Email
Jan 7, 2009
8:30 pm

I happened to be wrestling with MenuItems as well. The issue, I think, is that value is a property of the MenuItem object, not a property of the config object...
Philip Aaronson
p_aaronson
Offline Send Email
Jan 7, 2009
10:24 pm

Phil, What object is p_oValue ? Could you show an example how to get the object in the event handler ? Thanks, Pawel...
Pawel Sokolowski
psokolo
Offline Send Email
Jan 7, 2009
11:29 pm

Pawel, Sorry I wasn't very clear was I? The third argument passed in to onMenuItemClick by default is the MenuItem object selected I think? This is the wee...
Philip Aaronson
p_aaronson
Offline Send Email
Jan 8, 2009
1:31 am

Phil, This is great. I really don't know how I missed this property in Firebug. Thanks, Pawel...
Pawel Sokolowski
psokolo
Offline Send Email
Jan 8, 2009
2:08 pm

... property value ... <gonzalez@... ... selected ... handler ... My advice (until someone here posts a definitive answer): use Firefox and install Firebug: ...
cjavajim
Offline Send Email
Jan 7, 2009
8:31 pm

Pawel, 'text' is YUI property, 'value' is not. This is what I do. In the menuitem definition for the 'onclick' property you can define an additional object: ...
aniad
Offline Send Email
Jan 7, 2009
8:50 pm

Great. That's exactly what I needed. Dzieki, Pawel...
Pawel Sokolowski
psokolo
Offline Send Email
Jan 7, 2009
9:14 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help