【问题标题】:Durandal Passing parameter to custom dialogDurandal 将参数传递给自定义对话框
【发布时间】:2014-12-22 03:30:16
【问题描述】:

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

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

var CustomDialog = require('./customModal')

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

function activate(routedata){
....
}

要打开对话框,我有

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

如何将此路由数据传递给路径?

【问题讨论】:

  • 我不明白这个问题,也不够清楚,无法纠正错误

标签: modal-dialog durandal


【解决方案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;
});

【讨论】:

  • 似乎很适合显示返回为 return dialog.show('viewmodels/MyModel, activationData)。我可以得到activate方法中传递的参数。但是,当我使用 return dialog.show(this, activationData) 时,参数未定义。
猜你喜欢
  • 2014-03-16
  • 2012-05-06
  • 1970-01-01
  • 1970-01-01
  • 2019-06-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多