2015-11-06 42 views
0

我有一個radwindow,它顯示在對話框下。如你所知,在關閉這個對話框後,它的Close處理函數將被擊中。在那裏,我返回一個布爾值。 而我的問題是,我想直接從關閉處理程序獲取返回值,而不使用任何全局標誌我可以從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; 
     } 
    } 

確定,有沒有什麼辦法,我可以收到真|從處理程序這樣的錯誤值:

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

回答

0

一個抽象的解決辦法是:

回調機制是返回機制的一個很好的選擇。


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

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

2)對話框的密切監聽器訪問它

childCloseResponseListener(true); 

OR

childCloseResponseListener(false); 
相關問題