簡體   English   中英

我可以從RadWindow的關閉處理程序返回值嗎?

[英]Can I get a value returned from Close handler of a RadWindow?

我有一個radwindow,它顯示在對話框下。 如您所知,關閉此對話框后,將關閉其``關閉處理程序''功能。 在這里,我返回一個布爾值。 我的問題是我想直接從Close處理程序獲取返回值, 而不使用任何全局標志

請參考下面的代碼段以獲取更多詳細信息。

用於顯示對話框的函數:

function showDialog() {
        var url = "ChildPage.aspx";
        var wnd = window.radopen(url, 'Child Dialog');
        wnd.set_modal(true);
        wnd.setSize(400, 120);
        wnd.set_minHeight(300);
        wnd.set_minWidth(100);
        wnd.set_destroyOnClose(true);
        wnd.set_keepInScreenBounds(true);
        wnd.set_overlay(false);
        wnd.set_visibleStatusbar(false);
        wnd.set_visibleTitlebar(true);
        wnd.add_close(closeChildDialogHandler); //closeChildDialogHandler is Close handler
        wnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Resize);
        wnd.show();
        wnd.center();
    }

及其關閉句柄功能。 如您所見,我想在此處理程序中返回true | false值。

function closeChildDialogHandler(sender, args) {
        var flag = false;
        var objConfirmSQ = args.get_argument();
        if (objConfirmSQ != null && typeof objConfirmSQ['returnValue'] != "undefined") {
            console.log("objConfirmSQ['returnValue'] = " + objConfirmSQ['returnValue']);
            return true;
        }
        else {
            return false;
        }
    }

OK,有什么辦法可以從處理程序中接收true | false值,如下所示:

function myFunction(){
  var myVar = closeChildDialogHandler(unknown_param, unknown_param) //Not sure about this
}

一個抽象的解決方案是:

回調機制是返回機制的很好替代。


更具體的解決方案:
1)聲明一個功能。

childCloseResponseListener = function(myBooleanValue) {
/*Your handling for the boolean value when it gets here*/
}
childCloseResponseListener.bind(this);

2)從對話框的關閉監聽器訪問

childCloseResponseListener(true);

要么

childCloseResponseListener(false);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM