标签:kendo ui 关闭之后回传值至打开窗 promise window 异步窗口 window open then
前一篇promise window 在做的时候没有考虑仔细,只是实现了自己的关闭按钮,但是kendo window 自己的关闭按钮点击时没有回传值,并且造成了一个非常大的bug,非常抱歉,今天重新整理下。把原来的appdialog文件书写了下,有需要的重新替换下,非常抱歉
var contexts = {}; var dialogCount = 0; var app = { getDialog: function (obj) { if (obj) { return obj.__dialog__; } return undefined; }, close: function (obj) { var theDialog = this.getDialog(obj); if (theDialog) { var rest = Array.prototype.slice.call(arguments, 1); theDialog.close.apply(theDialog, rest); } }, initOption: function (obj) { var kendowindOption = { actions: ["Pin", "Refresh", "Maximize", "Minimize", "Close"], draggable: true, pinned: true, height: "450px", modal: true, resizable: true, title: "新增", width: "700px" }; if (obj) { if (obj.actions) { kendowindOption.actions = obj.actions; } if (obj.height) { kendowindOption.height = obj.height; } if (obj.width) { kendowindOption.width = obj.width; } if (obj.title) { kendowindOption.title = obj.title; } } return kendowindOption; }, showDialog: function (obj) { var dialogid = "dialog" + dialogCount; var dialogFilter = "#" + dialogid; if ($(dialogFilter) == undefined || $(dialogFilter).length === 0) $("body").append('<div id="' + dialogid + '"></div>'); var instance = $(dialogFilter).data("kendoWindow"); if (instance == undefined) { var kendowindOption = this.initOption(obj); $(dialogFilter).kendoWindow(kendowindOption); } var dfd = $.Deferred(); instance = $(dialogFilter).data("kendoWindow"); instance.bind("close", function () { var args = instance.closeValue; if (args) { if (args.length === 0) { dfd.resolve(); } else if (args.length === 1) { dfd.resolve(args[0]); } else { dfd.resolve.apply(dfd, args); } } else { dfd.resolve(); } $(dialogFilter).remove(); dialogCount = dialogCount - 1; delete instance.__dialog__; }); instance.__dialog__ = { close: function () { var args = arguments; var rest = Array.prototype.slice.call(args, 1); instance.closeValue = args; instance.close.apply(instance, rest); } }; dialogCount = dialogCount + 1; instance.center(); var url = obj.url; instance.refresh({ url: url }); instance.open(); return dfd.promise(); } };
利用kendo ui window创建自己的promise window (二),布布扣,bubuko.com
利用kendo ui window创建自己的promise window (二)
标签:kendo ui 关闭之后回传值至打开窗 promise window 异步窗口 window open then
原文地址:http://blog.csdn.net/zhangyuanwei88/article/details/38337699