[TIMOB-693] iOS: Ti.include in functions
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2016-08-19T16:32:50.000+0000 |
Affected Version/s | Release 3.0.0 |
Fix Version/s | n/a |
Components | TiAPI |
Labels | core |
Reporter | wallneradam |
Assignee | Ingo Muschenetz |
Created | 2011-04-15T02:34:37.000+0000 |
Updated | 2017-03-20T17:53:11.000+0000 |
Description
If I try to include a JS in a function with Ti.include, I can't access the local scope of the function from the included js. In the API documentation you wrote: "one or more filenames to include as if the Javascript code was written in place." In this way it is not true. Example:
var win1 = Titanium.UI.createWindow({
title:'Window 1',
backgroundColor:'white',
fullscreen:false
});
var globalv = 1;
function f1(){
var v = 2;
Ti.include('t2.js');
}
f1();
win1.open();
Ti.API.info("output of globalv is: " + globalv); // this outputs 1, as expected
Ti.API.info("output of v is: " + v); // this throws undefined exception, rather than the expected 2
Comments
- Stephen Tramer 2011-04-15
Unlikely include scenario, but should be investigated. Probably has to do with JS context scope. At best, a documentation change.
- Paul Dowsett 2011-05-16
- Junaid Younus 2012-08-13 Still able to reproduce this issue with the iOS simulator, TiSDK 2.2.0v20120810194112, TiStudio 2.1.1.201207271312.
- Chris Barber 2016-08-19
ti.include()
is deprecated since Titanium SDK 3.3.0 in favor ofrequire()
. - Lee Morris 2017-03-20 Closing ticket as ti.include() has been deprecated since Titanium SDK 3.3.0.