tags:

views:

49

answers:

2

I know it's possible to call the calling function, but is it possible to call the function calling that function. Ok ... that sounds a little confusing. Let me demonstrate:

pop.share(msg, function(response) {
    if(response) response = true;
    else response = false;
});

Basically a box pops up to ask the user to share. If the response is false I want to call pop.share ... thus displaying the popup modal forcing them to share. Ok, this is probably not good logic or practice for a live site.

I was just lying in bed and I got a though "can that actually be done". I was trying and trying with some test code and couldn't figure it out.

Edit: A do while would not work if it was a modal as it's not waiting for the users response, thus creating an infinite loop.

+1  A: 

Try obsolete arguments.caller? But since it is obsolete, it is not useful for live site.

https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Functions_and_function_scope/arguments/caller

czchen
`callee` is obsolete too as of ECMAScript 5.
casablanca
@casablanca: Nope, `arguments.callee` is not *obsolete* on ES5, under strict mode, accessing it will simply throw a `TypeError` exception. On non-strict code is still usable.
CMS
@CMS: Oh, my bad then.
casablanca
A: 

Try not obsolete arguments.callee.caller

Sergey Ilinsky