1

I have the following piece of code in parent that shows a child modal

exports.itemTap = function(args){
page.showModal("views/loopback/modal","My context here",function closeCallback(isSaved){
    console.log(isSaved);  //shows undefined on console
},false);
};

and I am closeing the child modal when the save button is clicked here

exports.save = function(args){
closeCallBack(true);
};

As you can see I am passing true as argument to the closeCallback function and printing the argument on the console in the parent but it always shows "undefined" and not "true" as expected. Is it some kind of bug? or I am doing something wrong here. Thanks in anticipation.

Eesa
  • 2,762
  • 2
  • 32
  • 51

1 Answers1

3

the callback is passed with this event :

<Page xmlns="http://schemas.nativescript.org/tns.xsd" 
      showingModally="onShowingModally">

and you can get the callback from

exports.onShowingModally = function(args) {
   var callback = args.closeCallback;
}

after that you can call it just like you did in your question.

Liviu Mihaianu
  • 289
  • 3
  • 13
  • Thanks for showing direction in my problem here : http://stackoverflow.com/questions/39050898/how-to-pass-parameters-to-modal-popup – Hardik Vaghani Aug 20 '16 at 06:59