Durandal将参数传递给自定义对话框

时间:2014-12-20 22:40:41

标签: modal-dialog durandal

我正在尝试实施一个自定义对话框,例如描述HEREHERE

的自定义对话框

在js文件中,我将模态的视图定义为

var CustomDialog = require('./customModal')

var DialogModel = require('./ MyModel') 但是,我的DialogModel需要在其activate方法中作为参数。 MyModel的路由定义为采用参数,其activate方法定义为

function activate(routedata){
....
}

要打开对话框,我有

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

如何将此路线数据传递到路径?

1 个答案:

答案 0 :(得分:1)

您应该在show中传递激活数据:

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

并在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;
});