Ext.js 確認框

2022-05-20 14:47 更新

描述

此消息框要求用戶確認以及對不同選項用戶選擇調(diào)用的不同方法為yes或no。

語法

下面是確認框的簡單語法。

 Ext.MessageBox.confirm('Confirm', Msg, optional callbackFunction());


下面是一個簡單的例子顯示用法。

<!DOCTYPE html>
<html>
<head>
    <link href="./ext-6.0.0/build/classic/theme-classic/resources/theme-classic-all.css" rel="stylesheet">
    <script src="./ext-6.0.0/build/ext-all.js"></script>
    <script type="text/javascript">
      Ext.onReady(function() {
         Ext.create('Ext.Button', {
            renderTo: Ext.getElementById('msgBox'),
            text: 'Click Me',
            listeners: {
               click: function() {
                  Ext.MessageBox.confirm('Confirm', 'Are you sure you want to do this ?', callbackFunction);
                  function callbackFunction(btn){
                  if(btn == 'yes') {
                     Ext.Msg.alert ('Button Click', 'You clicked the Yes button');
                  } else {
                     Ext.Msg.alert ('Button Click', 'You clicked the No button');
                  }
                     
                  };
               }
               
            }
         });
      });
   </script>
</head>
<body>
   <p> Click the button for alert box </p>
   <div id = "msgBox" ></div>
</body>
</html>

運行結果如下:

Ext.js 確認框


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號