Create your own promise window with the Kendo UI window

Source: Internet
Author: User

Create a new Appdialog.js file with the following code

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:t        Rue, Resizable:true, title: "Added", 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.__dialog__ = {close:function () {dialogcount = dialogCount-1;                Delete instance.__dialog__;                Instance.close ();                $ (dialogfilter). Remove (); var args = arguments;               if (args.length = = = 0) {dfd.resolve ();                } else if (args.length = = = 1) {dfd.resolve (args[0]);                } else {dfd.resolve.apply (DFD, args);        }            }        };        Dialogcount = Dialogcount + 1;        Instance.center ();        var url = obj.url;        Instance.refresh ({url:url});        Instance.open ();    return Dfd.promise (); }};

Create a new index.html page

<! DOCTYPE html>New Page2.html Page

<! DOCTYPE html>

Click the Open button effect as follows:



Click the Close button







This function is only done in the approximate, need to continue to improve. The promise operation in the Kendo UI is not well designed. It doesn't feel good to use.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.