ExtJs之addManagedListener

<!DOCTYPE html>
<html>
<head>
    <title>ExtJs</title>
    	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  		<link rel="stylesheet" type="text/css" href="ExtJs/packages/ext-theme-crisp/build/resources/ext-theme-crisp-all.css">
      <script type="text/javascript" src="ExtJs/ext-all.js"></script>
      <script type="text/javascript" src="ExtJs/bootstrap.js"></script>
      <script type="text/javascript" src="ExtJs/packages/ext-theme-crisp/build/ext-theme-crisp.js"></script>
</head>
<body>
<script type="text/javascript">

Ext.onReady(function(){
  function createFn(){
    alert('新建');
  }
  function openFn(){
    alert('打开');
  }
  function saveFn(){
    alert('保存');
  }
  Ext.create('Ext.toolbar.Toolbar',{
    renderTo: Ext.getBody(),
    bodyPadding: 5,
    width: 500,
    items: [
      {text: '新建', id: 'createBtn', iconCls: 'newIcon'},
      {text: '打开', id: 'openBtn', iconCls: 'openIcon'},
      {text: '保存', id: 'saveBtn', iconCls: 'saveIcon'},
      {text: '销毁新建按钮', handler: function(){
        Ext.getCmp('createBtn').destroy();
      }}
    ]
  });
  var createBtn = Ext.getCmp('createBtn');
  createBtn.on('click', createFn);
  createBtn.addManagedListener(Ext.getCmp('openBtn'), 'click', openFn);
  createBtn.addManagedListener(Ext.getCmp('saveBtn'), 'click', saveFn);
});
</script>
<body>
</body>
</html>

  ExtJs之addManagedListener_第1张图片

你可能感兴趣的:(ExtJs之addManagedListener)