0
     return{     // this code is in index.js
        addItem: function () {
        alert("working");
        Newram.show().then(function (response) `***// Calling show functionin Newram.js***`
        {
            var c = response;
        }
            );
    }}
     // In Newram.js while closing the popup i tried to send data to the **response** in index.js but empty string or undefined  is showing

var AddItem = function () {
    var self = this;

        self.Name = ko.observable('jo'),
        self.Price = ko.observable(100),
        self.Sales = ko.observable("good")
        self.data1= {name:self.Name() };

};



AddItem.prototype.closeDialog = function () {
    dialog.close(this, self.Name);
};

I cant able to pass an observable data while closing a popup even i tried this code( dialog.close(this,ko.toJS(self.Name))).....cant able to get the data in response but if i pass a string it is available in the response

Joel
  • 1
  • 2

1 Answers1

0

You have to to pass a string back from the modal dialog. So in your dialog.close try this...

var response = JSON.stringify({ Name: self.Name() })
dialog.close(this, response);

Then you can access the value in your index.js like this...

Newram.show().then(function (response) {
   var parsed = JSON.parse(response)
   var c = parsed.Name;
}
Dan Leksell
  • 510
  • 5
  • 6