Passing paramiters to setTimeout
The dialect of Java Script interpreted by Titanium Mobiles runtime is not allowing parameters to be passed to setTimeout functions.
Can anyone help with best practices on setTimout parameter passing.
This works on my web pages but not in Titanium on iPhone, iPad, or Android:
window.setTimeout(function (a,b) {
//do something with a and b
},10,someString,someObject);
3 Answers
-
I feel like perhaps I'm misunderstanding your question, but this works fine for me:
function myFunc(myArg) { Titanium.API.info(myArg); } var thing = 'some value'; scrollTimeout = setTimeout(function() {myFunc(thing);}, 100);
That outputs 'some value' in the log window - is that the kind of thing you're after?
Toby
-
Not sure if this is the correct context but this is the only way I've been able to get setTimeout to work..although I've never had to pass parameters but I don't see why it wouldn't work.
Hope it helps!
setTimeout(function() { yourFunction(a,b); }, 1000 );
-
No answers? :S