I'm using IBM Worklight Developer Edition 6.1 installed in Eclipse Juno as my IDE and backbonejs as my main javascript framework for my project.
My index.html
<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
<script>window.$ = window.jQuery = WLJQ;</script>
<script data-main="js/main" src="js/libs/require/require.js"></script>
</head>
<body>
</body>
</html>
My main.js
require.config({
paths: {
jquery: 'libs/jquery/jquery-min',
underscore: 'libs/underscore/underscore-min',
backbone: 'libs/backbone/backbone-min',
templates: '../templates',
bootstrap: 'bootstrap.min',
initOptions: 'initOptions',
biiRibMobile: 'biiRibMobile',
messages: 'messages'
},
});
require(['app', ], function(App) {
App.initialize();
});
My app.js
// Filename: app.js
define(['jquery', 'underscore', 'backbone', 'router', // Request router.js
'bootstrap', 'initOptions', 'biiRibMobile', 'messages', ], function($, _, Backbone, Router, bootstrap, initOptions, biiRibMobile, messages) {
var initialize = function() {
// Pass in our Router module and call it's initialize function
Router.initialize();
};
return {
initialize: initialize
};
});
My initOptions.js
var wlInitOptions = {
logger : {enabled: true, level: 'debug', stringify: true, pretty: false,
tag: {level: false, pkg: true}, whitelist: [], blacklist: []},
analytics : {
enabled: false
//url : ''
}
};
if (window.addEventListener) {
window.addEventListener('load', function() { WL.Client.init(wlInitOptions); }, false);
} else if (window.attachEvent) {
window.attachEvent('onload', function() { WL.Client.init(wlInitOptions); });
}
Thanks a lot in advance.
@DavidDhuyveter has a good answer in the comments. I had this problem on a Mac and on a Windows PC. His answer fixed my Mac issues.
For Windows, the temp folder should be in /Users/you/AppData/Local/Temp/1/ or something along those lines.
EDIT David comments were deleted. This is the original:
same problem with WL 6.1.My app did not work with the link "preview as common ressources", but it worked with the mobile browser simulator
I Solved it by exiting eclipse then deleted wlbuildressources and wlpreview folder in tmp folder (/tmp on linux). After that, I restarted eclipse and it worked. However, it is a bug in 6.1.
This problem actually happens a lot and it is actually really frustrating. Sometimes everything will be working for awhile and out of nowhere, this lovely error pops up. Something you can do instead (which has worked for me consistently) is:
I would try that first and see what it does. If not, you can do the trusted method of removing and re-importing.
I think I finally figured out an easy workaround for this one.
Right click on your project name in Eclipse, choose Close Project and then right-click again and choose Open Project. This fixed my broken preview pages.
What helps me each time when I run into this problem while opening the app from the Worklight console is that I right-click on the app, choose Run As -> Preview before I attempt to load it from the Worklight console. After that, app starts working no matter from where I launch it.
The quickest workaround for me is to remove the project and then add the project into the workspace again. This need not suffer from renaming the project or other process.