2017-07-22 281 views
0

嗨,我一直在使用Extjs的HTML編輯器。我想定製的HTML編輯器,就像我必須顯示一個自定義的警告框,當我們點擊按鈕toolbar.how我們可以做到嗎? 在此先感謝。Extjs的HTML編輯器和如何自定義編輯器

+0

問題有點模糊。爲什麼樣的警報?什麼工具欄?什麼按鈕?任何你想讓警報看起來像什麼樣子的圖像,以及你什麼時候想要它顯示出來? –

回答

2
Ext.define('MyApp.ux.MyOwnHtmlEditor',{ 
    extend: 'Ext.form.field.HtmlEditor', 
    xtype: 'myhtmleditor', 
    getToolbarCfg: function() { 
     // get original toolbar: 
     var toolbar = this.callParent(arguments); 
     // add custom item: 
     toolbar.items.push({ 
      xtype: 'button', 
      iconCls: 'x-fa fa-question-circle', 
      handler: function() { 
       Ext.Msg.alert('Dear user!', 'No, we won\'t help you!'); 
      } 
     }); 
     // Modify handler of existing button: 
     toolbar.items[3].handler = function() { 
      Ext.MessageBox.alert('Dear user!', 'If you want Italic, please go to Italy!'); 
     }; 
     // return toolbar to calling function 
     return toolbar; 
    } 
}) 

然後使用它像這樣:

{ 
    xtype: 'myhtmleditor' 
} 

Example fiddle