Coding differences

Although BlackBerry WebWorks has been significantly re-architected to align with the Cordova standards, if you have previously created a WebWorks app for BlackBerry 10, there are really only a few small changes you'll need to make to your HTML and JavaScript code to make it compatible.

Include cordova.js instead of webworks.js

In BlackBerry WebWorks apps, you needed to include webworks.js to launch the BlackBerry WebWorks application runtime. For example:
<script src="local:///chrome/webworks.js" type="text/javascript"></script> 
In BlackBerry WebWorks 2.0, you include cordova.js instead. You should replace all instances of webworks.js with cordova.js. For example:
<script src="local:///cordova.js" type="text/javascript" ></script>

Listen for the deviceready event instead of the webworksready event

In BlackBerry WebWorks apps, your app needed to listen for the webworksready event, and could not call any BlackBerry WebWorks APIs until the event had occured. For example:
document.addEventListener('webworksready', function(e) {
.
.
.
}
In a BlackBerry WebWorks 2.0 project, you'll need to listen for the deviceready event instead. You should replace all instances of webworksready with deviceready. For example:
document.addEventListener('deviceready', function(e) {
.
.
.
}

Last modified: 2014-03-10

comments powered by Disqus