【发布时间】:2014-08-15 03:13:56
【问题描述】:
我的视图模型中有以下内容:
dialog.getContext().reposition(vm);
但这不起作用,因为我应该通过view,而不是viewmodel。我如何 - 从视图模型中 - 访问其相应的视图?
【问题讨论】:
-
viewmodel中的附加函数在viewmodels对应的view中传递。
标签: durandal durandal-2.0
我的视图模型中有以下内容:
dialog.getContext().reposition(vm);
但这不起作用,因为我应该通过view,而不是viewmodel。我如何 - 从视图模型中 - 访问其相应的视图?
【问题讨论】:
标签: durandal durandal-2.0
从您的 viewModel 访问视图 您有 detached、compositionComplete、attached 和 compositionComplete 处理程序可供选择。
例如来自attached:
function attached(view, parent) {
console.log("This is the current view",view);//this will log the view HTML
$(view).find(".smallLoader").fadeOut();// Now fadeOut .smallLoader from this view
}
var viewModel = {
activate: activate,
title: 'Home',
attached: attached
};
return viewModel;
【讨论】: