createWindow and onLoad
Hey all,
So, I'm trying to create a window and listen to its onload event, but, to no avail. This is how I'm creating/launching my window (w/ a correct url ;) :
var newAccountWin = Titanium.UI.getCurrentWindow().createWindow("url");
newAccountWin.setWidth(500);
newAccountWin.setHeight(550);
newAccountWin.open();
This works fine, but, my attempts to hook the onload events do not:
newAccountWin.onload=function(){alert("onload")}
-
newAccountWin.addEventListener("load",function(){alert("onload")},false)
-
Titanium.UI.windows[1].onload=function() {alert("load")}//windows[1] should be equal to newAccountWin
None, of the above work. Is this even possible? Am I overlooking something stupid? Do I need to do anything with getDOMWindow()? Any help would be greatly appreciated.
Thanks!
4 Answers
-
Ah hah, use "page.load" instead of load (or Titanium.PAGE_LOAD):
newAccountWin.addEventListener(Titanium.PAGE_LOAD,function() { alert("loaded") },false)
Seems to fire twice, but, atleast we're making progress!
-
'load' does not appear to be a valid event unless you are throwing it from somewhere else:
http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.Window-object
-
Nice! I'm creating a desktop app; didn't think to look in the mobile docs ;)
But, ya, you're right… no load event :(
Guess I'll have to go another route.
Thanks!
-
Have you tried "focus"?
newAccountWin.addEventListener("focus", function() { .... });