我想我明白了。它不像我希望的那样漂亮,但我很高兴能够按原样重用对话框插件和转换机制。
这是我使用的对话上下文:
define(['jquery', 'knockout', 'transitions/entrance', 'plugins/dialog'], function ($, ko, entrance, dialog) {
return {
addHost: function (theDialog) {
//Cheat - only applies to my project (where I want to put the dialog - side-by-side with the current active view)
var container = $('div.document-edit');
var host = $('<div></div>').appendTo(body);
theDialog.host = host.get(0);
//Cheat - the view I want to hide (while the dialog is displayed)
theDialog.activeView = container.find("div[data-active-view='true']:first").get(0);
},
removeHost: function (theDialog) {
var context = {
activeView: theDialog.host,
child: theDialog.activeView,
triggerAttach: function () { } //Cheat - no need for triggerAttach
};
entrance(context).then(function () {
ko.removeNode(theDialog.host);
});
},
compositionComplete: function (child, parent, context) {
var theDialog = dialog.getDialog(context.model);
context.activeView = theDialog.activeView;
//Cheat - no need for triggerAttach
context.triggerAttach = function () { };
entrance(context).then(function () { });
}
};
});