[TIMOB-6231] Android: Ti.include doesn't work correctly in event handler
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2012-02-10T00:26:40.000+0000 |
Affected Version/s | Release 1.7.0, Release 1.7.5, Release 1.7.6, Release 1.8.0.1 |
Fix Version/s | n/a |
Components | Android |
Labels | parity |
Reporter | Arthur Evans |
Assignee | Ping Wang |
Created | 2011-11-17T23:39:02.000+0000 |
Updated | 2012-02-10T00:26:40.000+0000 |
Description
This is related to the customer issue reported in TIMOB-1662. In trying to describe the behavior of Ti.include to resolve the related doc bug, TIMOB-4108, I came across the following parity issue: Ti.include works correctly when called from an event handler on iOS, but not on Android. Consider the following code:
app.js
:
var win1 = Titanium.UI.createWindow({
title:'Window 1',
backgroundColor:'blue',
fullscreen:false
});
win1.open();
var testVar1 = "I can see the global context.";
var testMe = function(){
Ti.API.info("In the function");
Ti.include('include_test2.js');
Ti.API.info("testVar2 defined in include_test2.js and output in app.js: " + testVar2);
};
testMe();
win1.addEventListener('click', function()
{
Ti.API.info("In the event handler");
testMe();
});
win1.fireEvent('click', {});
And the include file, include_test2.js
:
var testVar2 = "Variable defined in the include file.";
Ti.API.info("In the include file.")
Ti.API.info("testVar1: " + testVar1);
On iOS, whether the testMe function is called directly or from inside the event handler, the include file can access the global context. On Android, though, it succeeds when the function is called directly, and fails with a reference error when called from the event handler.
Attached new test case (whole small runnable project).
Reproducible Steps
1. Press "Click button"Attachments
File | Date | Size |
---|---|---|
namespace2.zip | 2011-12-09T12:07:28.000+0000 | 2321943 |
Can not reproduce with the latest master.