2013-06-12 51 views
0

我正在使用jQuery EasyUI框架。我想在關閉窗口中輸入確認消息,如「您確定要關閉窗口嗎?」。如果答案是真的,那麼關閉,否則不要關閉窗口。jQuery EasyUI:關閉窗口確認

我該怎麼做?

回答

0

這個功能不是直接由Easy-UI 提供,如果你想,那麼你需要禁用關閉按鈕的窗口像

.panel-tool-close 
    { 
     display:none !important; 
    } 

,並添加自定義工具欄 這樣在功能的document.ready

jQuery('#divSeguimientos').window({ 
     collapsible:false, 
     minimizable:false, 
     maximizable:false, 
     tools:[{ 
      iconCls:'icon-cancel', 
      handler:function(){ 
       if(confirm('Are you sure to close the window?')) 
        { 
         closeDivSeguimientos(); 
        } 
        else 
        { 

        } 

      } 
     }] 
    }); 
+0

感謝您的幫助 – Napster

1

嘗試

$.messager.confirm('Confirm', 'Are you sure to exit this system?', function(r){ 
    if (r){ 
     // exit action; 
    } 
}); 

看到Messanger API

+0

我怎樣才能把它放在窗口的關閉事件? – Napster

+0

瀏覽jQuery窗口關閉事件。 http://api.jquery.com/unload/ –

1

試試這個,

$('#windowid').window({ 
onBeforeClose: function(){ 
    $.messager.confirm('Confirm', 'Are you sure to exit this system?', function(r) 
      { 
      if (r){ 
        return true; 
       } 
      else{return false;} 
      });      
} 
}); 
0

此功能不是由簡單的用戶界面提供。 所以你要隱藏或關閉按鈕集沒有設定CSS顯示屬性。

還設置關閉按鈕類。

.panel-tool-close 
    { 
     display:none !important; 
    } 

請試試這個。

tools:[{ 
      iconCls:'icon-cancel', 
      handler:function(){ 
       if(confirm('Are you sure to close?')) 
        { 
         closeDiv(); 
        } 
        else 
        { 

        } 

      } 
     }] 
+0

感謝您的幫助 – Napster