jpo
jpo

Reputation: 4059

Durandal Passing parameter to custom dialog

I am trying to implement a custom dialog like the one describe HERE or HERE

In the js file I fdefined the modal's view as

var CustomDialog = require('./customModal')

var DialogModel = require('./MyModel') However, my DialogModel requires as parameter in its activate method. The route for the MyModel is defined to take a parameter and its activate method is defined as

function activate(routedata){
....
}

To open the dialog, I have

 var routedata = 90;
 this.dialog = new CustomDialog('My title', new DialogModel());
 this.dialog.show()

How do I pass this route data to the path?

Upvotes: 1

Views: 470

Answers (1)

Dziamid
Dziamid

Reputation: 11579

You should pass activation data in show:

 var routedata = 90;
 this.dialog = new CustomDialog('My title', new DialogModel());
 this.dialog.show(routedata);

And proxy it in your CustomDialog:

define(['plugins/dialog'], function (dialog) {
    var CustomModal = function (title, model) {
        this.title = title;
        this.model = model;
    };

    CustomModal.prototype.ok = function() {
         dialog.close(this, this.model);
     };

    CustomModal.prototype.show = function(activationData){
       return dialog.show(this, activationData);
    };

    return CustomModal;
});

Upvotes: 1

Related Questions