剑道窗户一旦被摧毁,便不会再次打开 [英] Kendo Window not opening again once it is destroyed

查看:111
本文介绍了剑道窗户一旦被摧毁,便不会再次打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种情况,一旦我的工作完成,我需要销毁剑道窗口. 只需单击一下按钮,便会打开Kendo窗口,并在其工作完成时销毁.

I have a situation where I need to destroy kendo window once my job is complete. Kendo window opens up on a button click and destroys when its job is complete.

但是现在我有一个问题,一旦按钮被销毁,我将无法再次打开该窗口.

But now I have a problem that I cannot open the window again on that button click once it is destroyed.

我的Kendo窗口代码为:

My Kendo Window code is :

        var Snapshotwindow = $('#newWindow');
        Snapshotwindow.kendoWindow({
            width: "500px",
            height: "267px",
            resizable: false,
            sortable: false,
            modal: true,
            draggable: false,
            title: "New Window",
            visible: false,
            appendTo: "#AppBody",
        });
        Snapshotwindow.data("kendoWindow").center().open();

我该如何实现?

一旦窗口被销毁,我可以重新初始化它吗?

Can I re initialize the window once it is destroyed?

推荐答案

在销毁Kendo窗口小部件时,它将从DOM中删除其HTML元素,包括从中创建根元素的根元素.这就是为什么您无法再次打开窗口的原因.使用Window小部件时,这为您提供了两种基本方法:

When a kendo Window widget is destroyed, it removes it's HTML elements from the DOM including the root element from which it was created. This is why you are unable to open the window a second time. This leaves you with two basic approaches when using the Window widget:

  1. 第一次创建窗口小部件,并保留对其的引用.请勿在关闭时破坏,并使用参考重新打开后续时间.

  1. Create the widget first time around, holding a reference to it. Don't destroy on close, and re-open subsequent times using the reference.

if (Snapshotwindow == null) {
    Snapshotwindow = $('#newWindow').kendoWindow({
        width: "500px",
        height: "267px",
        resizable: false,
        sortable: false,
        modal: true,
        draggable: false,
        title: "New Window",
        visible: false,
        appendTo: "#AppBody",
    }).data("kendoWindow");
}
Snapshotwindow.center().open();

  • 在DOM上添加一个新元素,在显示它之前将其变成一个窗口小部件.可以安全地销毁,并且此过程随后会根据需要重复多次.

  • Append a new element to the DOM, turning that into a window widget before showing it. Can be safely destroyed, and the process subsequently repeated as many times as you like.

    <script id="modal-editor-window" type="text/x-kendo-template">
        <!-- your window content here -->
    </script>
    
    <script type="text/javascript">
        var options = {
            title: "Edit",
            modal: true,
            visible: false,
            deactivate: function () {
                this.destroy();
            }
        };
    
        var mew = $.parseHTML($("#modal-editor-window").html().trim());
        $("body").append(mew);
    
        var mw = $(mew).kendoWindow(options).data("kendoWindow");
        mw.center().open();
    </script>
    

  • 由于您说需要销毁窗户,因此选择方法2是可行的;我建议使用kendo模板(如上所示)最容易完成加载新DOM元素的操作.

    Since you say you need to destroy the window, option 2 is the way to go; I would suggest that loading the new DOM element is probably easiest to achieve by using a kendo template (as shown above).

    这篇关于剑道窗户一旦被摧毁,便不会再次打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆