Constantly getting this error when LiveView is trying to recompile. Can anyone shed some light on how the LiveView works? The object "Alloy.Globals.layout.activityList" DOES exist, but perhaps the LiveView only recompile parts of the code where Alloy Globals doesn't exist?
[ERROR] : Script Error {
[INFO] : {
[ERROR] : column = 36;
[ERROR] : line = 28;
[ERROR] : message = "undefined is not an object (evaluating 'Alloy.Globals.layout.activityList')";
The "Movies" example app from Appcelerator uses the same logic of having a layout object in Alloy.js. Im doing the exact same thing, but its messing upp the recompile about 8 out of 10 times.
/**
* Calculate element dimensions for given screen size
* @param {Object} size containing width and height properties
*/
Alloy.Globals.calculateElementDimensions = function(size) {
var layout = {};
layout.device = {};
layout.device.width = size.width;
layout.device.height = size.height;
// lists
layout.activityList = {};
layout.activityList.cell = {};
layout.activityList.cell.width = size.width;
layout.activityList.cell.height = 60;
layout.activityList.cell.spacing = 1;
layout.activityList.cell.dateView = {};
layout.activityList.cell.dateView.width = layout.activityList.cell.height;
layout.activityList.cell.dateView.height = layout.activityList.cell.height;
layout.activityList.cell.detailsView = {};
layout.activityList.cell.detailsView.width = (layout.activityList.cell.width - layout.activityList.cell.dateView.width) - 50;
layout.activityList.cell.detailsView.height = layout.activityList.cell.height;
layout.activityList.cell.deleteView = {};
layout.activityList.cell.deleteView.width = size.width * 0.2;
layout.activityList.cell.deleteView.right = (0 - layout.activityList.cell.deleteView.width);
return layout;
};
// Calculate element dimentsions
Alloy.Globals.layout = Alloy.Globals.calculateElementDimensions(Alloy.Globals.Device);
Alloy.Globals.getCalculatedWidth = function(_percentage){
return (Alloy.Globals.Device.width * (_percentage / 100));
};
#Update
I think I might have found whats triggering the error. It seems its not actually a problem with running the new updated code, but rather that there is an error before the shut down and refresh.
**[INFO] : [LiveView] Reloading App**
[INFO] : Login win close
[INFO] : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[INFO] : validateLogInInfo
[INFO] : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[INFO] : UI SHUTDOWN COMPLETE. TRYING TO RESUME RESTART
[INFO] : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[INFO] : RUNNING CODE IN ACTIVITIES.JS
[INFO] : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
**[ERROR] : Script Error {
[ERROR] : column = 36;
[ERROR] : line = 42;
[ERROR] : message = "undefined is not an object (evaluating 'Alloy.Globals.layout.device')";
[ERROR] : stack = "Controller\ncreateController\nController\ncreateController\nvalidateLogInInfo\n";
[ERROR] : }
Alloy.createController('login', {
callback: validateLogInInfo
}).getView().open();**
The error seem to have to do with that I am running code in the window.close event handler. For example in one controller I do this:
Alloy.createController('login', {
callback: validateLogInInfo
}).getView().open();
And in login.js i do:
$.win.addEventListener('close', function(){
log('Login win close');
args.callback();
});
I guess the callback is then trying to run when LiveView is trying to close down and refresh, hence the compiler error. Removing the callback in the windoew.close event results in a successful reload
[INFO] : [LiveView] Reloading App
[INFO] : Login win close
[INFO] : UI SHUTDOWN COMPLETE. TRYING TO RESUME RESTART
SO, is providing a callback to the close event of an other controller completely the wrong way to do this stuff?
