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

ReferenceError: Can't find variable: blackberry

Hi, I dont know what I'm doing wrong with webworks, but when i use remote debug on the dev alpha, I always get:

ReferenceError: Can't find variable: blackberry 

 here is my whole code:

<!DOCTYPE html>
<html>
<head>
    <title>Test</title>
    <link rel="stylesheet" href="BlackBerry-JQM-all.css" />
    <script src="BlackBerry-JQM-all.js"></script>
</head>
<body>
	[...]
    <script type="text/javascript" src="local:///chrome/webworks.js"></script>
    <script src="code.js"></script>
</body>
</html>

 and the code.js:

document.addEventListener("webworksready", start());

function start() {
    // context menu
    blackberry.ui.contextmenu.addItem([
		blackberry.ui.contextmenu.CONTEXT_ALL
    ], {
        actionId: 'delete',
        label: 'Delete',
        icon: 'local:///delete.png'
    }, function () {
        alert('Delete!');
    });
}

$(document).ready(function () {
    [...]
});

 

why i get the Can't find variable: blackberry ?

Plase "+Like" my post if it was helpful.
Contributor
Gerii
Posts: 33
Registered: ‎04-30-2012
My Device: PlayBook, DevAlpha

Re: ReferenceError: Can't find variable: blackberry

How does your config.xml look like? Did you add <feature id="blackberry.ui.contextmenu" /> to it?

Developer
smartek
Posts: 281
Registered: ‎05-31-2012
My Device: Playbook

Re: ReferenceError: Can't find variable: blackberry

Yes i have
Plase "+Like" my post if it was helpful.
Developer
The_Anomaly
Posts: 322
Registered: ‎08-06-2012
My Device: Dev Alpha / Playbook / Curve 9300

Re: ReferenceError: Can't find variable: blackberry

The next logical question for me is: What BB10 SDK are you using?  Is it the latest 1.0.3.8?

 

That error happens when you call a Blackberry API, like you are calling the contextmenu, AND the api is not found.  So you have followed the documentation well, but I remember the webworks.js call was different before this.  In fact previously we had to copy it into our project then it changed... anyway, check the SDK version you have installed OR are trying to compile with.  You may even have multiple versions installed.

If it helped you, click like. :smileyhappy: