0

I want invoke event after click OK button on popup using remote and mouse (TV app). Do you have any idea how can I get access to arg variable which I get with popup callback (after clicked OK button) by ENTER on remote when I click on this button using mouse?

function PopUp("napis", function callback (arg) {
 if (arg === sth)
  doSth();
})

$('button').click (function () { 
 if (arg === sth) //how can I access arg which will be the same with arg in callback function
  doSth(); 
})
norbi123
  • 41
  • 1
  • 8

1 Answers1

0

The variable is only available in that scope, so to access it elsewhere, you can set another variable to the same value. Something like this:

var myArg;

funkcja PopUp("napis", function callback (arg) {
 myArg = arg;
 if (arg === sth)
  doSth();
})

$('button').click (function () { 
 if (myArg === sth) //this will access myArg which will be set in the callback.
  doSth(); 
})
sachleen
  • 30,730
  • 8
  • 78
  • 73
  • but when I first use mouse myArg will be undefined and it is not what I want achive... because PopUp callback is invoked after click ok button on popup using remote – norbi123 Jan 12 '13 at 23:22
  • So you want to get the value of a variable that hasn't been set yet..? – sachleen Jan 12 '13 at 23:28