KendoUI Window Flashes Old Content

笑着哭i 提交于 2019-12-10 21:12:55

问题


Using KendoUI to display a popup window, I've noticed that if I reuse an existing window by calling refresh it briefly displays the old content until the AJAX request completes.

My code:

function clickHandler(evt) {
    evt.preventDefault();

    var dta=this.dataItem($(evt.currentTarget).closest("tr"));

    convertWindow.refresh({ type: "GET", url: "CallMeConvert?AppointmentId="+dta.AppointmentId});
    convertWindow.center();
    convertWindow.open();
    }

Is there any way to prevent this happening, or must I destroy and recreate the window every time?


回答1:


It was, in the end, quite simple. You just need to clear the HTML immediately before doing the reset, like so:

$("#convert-window").html("");
convertWindow.refresh({ type:"GET", url:url }).center().open();



回答2:


Try opening the window not when you start the refresh but when it finishes. What you need to do is use the refresh event:

function clickHandler(evt) {
    evt.preventDefault();

    var dta=this.dataItem($(evt.currentTarget).closest("tr"));

    converWindow.bind("refresh", function() {
        convertWindow.center().open();
    });

    convertWindow.refresh({ type: "GET", url: "CallMeConvert?AppointmentId="+dta.AppointmentId});
}

NOTE You actually don't need to bind refresh event every time, you can define it during the Window initialization.

var convertWindow = $("#my_window").kendoWindow({
    ...
    refresh : function () {
        convertWindow.center().open();
    }
});


来源:https://stackoverflow.com/questions/19171552/kendoui-window-flashes-old-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!