Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10167] MobileWeb: Variable defined in root window context is not accessible by included javascript file

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Fix
Resolution Date2017-06-26T22:11:23.000+0000
Affected Version/sRelease 2.1.0
Fix Version/sn/a
ComponentsMobileWeb
Labelscommunity, core
ReporterTaka Torimoto
AssigneeEric Merriman
Created2012-07-25T12:57:51.000+0000
Updated2017-08-24T20:57:29.000+0000

Description

Please see my Q&A entry: http://developer.appcelerator.com/question/140151/cant-access-global-var-tifrom-included-function

In app.js: ###

var win = Ti.UI.createWindow({ url: "app2.js", }); win.open();

In app2.js: ###

var steps = ['on', 'off']; Ti.include('test.js');

In test.js: ###

alert(steps[0]); This fails. But if I were to move the steps definition to app.js, it works. The 2.1.0 API docs state: "The included JavaScript is interpreted in the current root execution context -- that is, either app.js or in the root context of a window opened with the url property." So I assume the above should work; i.e. I should be able to define a global variable in the Windows context (app2.js) and have access to it from the included file (test.js) - but it seems to only work if I define the variable in app.js ONLY.

Comments

  1. Lee Morris 2017-08-24

    Mobile Web has been deprecated and will be removed in fixVersion 7.0.0.

JSON Source