0

I have a Cordova/PhoneGap application where I create directories on the phone persistent storage. I have a problem passing the context to the Cordova plugin API. I use the DirectoryEntry.getDirectory() method who receives two callbacks - one for success and the second is for error. The success method signature is function success(dirEntry) { ... }, where I want to use it like this:

var x = // some data collected
rootdor.getDirectory("mydir",  {create: true, exclusive: false}, success, fail); 
// store x in the retrieved/created directory, can be done in the success method

I need help with the last part - how do I pass reference to x in the success callback.

David Rabinowitz
  • 29,904
  • 14
  • 93
  • 125

1 Answers1

0

Ok, I've learned about JavaScript scopes which solves the case. The question referred by @sleepwalker was a great help.

Also if someone is interested, I suggest to have a look at the implementation of onPhotoCaptureSuccess() in this code.

David Rabinowitz
  • 29,904
  • 14
  • 93
  • 125