Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
Posts: 268
Registered: ‎08-19-2009
My Device: Bold 9700
Accepted Solution

blackberry.ui.menu.MenuItem being invoked when instantiated

I'm creating a menu item:

 

var regPush = new blackberry.ui.menu.MenuItem(false, 1, "Push Registration", openBISPushListener());
blackberry.ui.menu.addMenuItem(regPush);

But openBISPushListener() is being called during this menu item instantiation. When I comment out the menu item lines, the code isn't called.

 

Any ideas?

Developer
Posts: 68
Registered: ‎03-01-2011
My Device: Not Specified

Re: blackberry.ui.menu.MenuItem being invoked when instantiated

The problem is that you are defining and at the same time executing the callback function for your menuItem.

 

Please see if attaching the callback method works for you : 

 

var regPush = new blackberry.ui.menu.MenuItem(false, 1, "Push Registration", openBISPushListener);

 

Notice that I just removed the () on your openBISPushListener.

Developer
Posts: 268
Registered: ‎08-19-2009
My Device: Bold 9700

Re: blackberry.ui.menu.MenuItem being invoked when instantiated

Brilliant, thank you.