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
smartek
Posts: 281
Registered: ‎05-31-2012
My Device: Playbook
My Carrier: o2
Accepted Solution

Problem with context menu: uncaught typeError: cannot read property CONTEXT_IMAGE of undefined

[ Edited ]

Hi, i wanted to try the context menu with the following javaScript function:

function addMyItem() {
        var myItem = { actionId: 'Delete', label: 'Delete', icon: 'delete.png' },
            contexts = [blackberry.ui.contextmenu.CONTEXT_IMAGE, blackberry.ui.contextmenu.CONTEXT_INPUT];
        blackberry.ui.contextmenu.addItem(contexts, myItem, function () { console.log('hi') });
    }

 i have this function from the API Reference[1]

 

when i try to run this function I get the error:

uncaught typeError: cannot read property CONTEXT_IMAGE of undefined

 


what is wrong here?

 

EDIT: I have the feature ID in my config

<feature id="blackberry.ui.contextmenu" />

 

 

[1] https://developer.blackberry.com/html5/apis/blackberry.ui.contextmenu.html

Plase "+Like" my post if it was helpful.
Please use plain text.
BlackBerry Development Advisor
chadtatro
Posts: 614
Registered: ‎10-01-2009
My Device: Z10
My Carrier: Bell

Re: Problem with context menu: uncaught typeError: cannot read property CONTEXT_IMAGE of undefined

I have a bit of a different approach, but have verified it was working for me when tested.

 

var share = {
  actionId: 'share',
  label: 'Share Image',
  icon: '../images/share.png'
};

var contexts = [blackberry.ui.contextmenu.CONTEXT_IMAGE];


blackberry.ui.contextmenu.addItem(contexts, share, function(){
  alert('Sharing is caring!');
});

 

If this isn't working, can you let us know which SDK you're using, and we can retest if necessary?  

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Please use plain text.
Regular Contributor
hari1
Posts: 60
Registered: ‎12-29-2012
My Device: None right now
My Carrier: BSNL

Re: Problem with context menu: uncaught typeError: cannot read property CONTEXT_IMAGE of undefined

[ Edited ]

Edit: Sorry message was posted in wrong thread.

Please use plain text.