Search code examples
titaniumappceleratortitanium-mobiletitanium-alloy

How can I get current opened window in Titanium?


I want to get the current opened Window object. such as in demo.js

console.info("=====current_window=====")
console.info(Ti.UI.currentWindow)
console.info(Ti.UI.getCurrentWindow())

I hope it is output: demo or $.demo (if I don't give Id on this Window) but I got that:

[INFO] [iphone, 8.2, 192.168.1.112] =====current_window=====
[INFO] [iphone, 8.2, 192.168.1.112]
[INFO] [iphone, 8.2, 192.168.1.112]

Any suggestions?


Solution

  • As the documentation says:

    This property is only available when using the Titanium.UI.Window.url property to load JavaScript files in their own contexts.

    This property has been removed since 3.6.0/4.0.0 and has been deprecated for long.

    You are supposed to use CommonJS (require() - not Ti.include()) to organise contexts and keep track of the current open window yourself, depending on how you manage your windows.