パネルに並べたボタンをタップすると関数が実行されるようにしましょう。タップイベントの応答はhandlerプロパティに設定します。
次のbutton1のhandlerにはfunctionステートメントが直接書いてあります。button2のhandlerではユーザー定義したmyFuncを実行します。
サンプルを試す
index.js
次のbutton1のhandlerにはfunctionステートメントが直接書いてあります。button2のhandlerではユーザー定義したmyFuncを実行します。
サンプルを試す
index.js
Ext.setup({ onReady: function(){ var myFunc = function(){ alert('myFuncを実行しました。'); }, var buttons = [{ ui: 'small', text: 'button1', handler: function(){ alert('button1です。'); } }, { ui: 'small', text: 'button2', handler: myFunc }] var myPanel = new Ext.Panel({ fullscreen: true, dockedItems: [ { dock : 'top', xtype: 'toolbar', ui : 'light', items: buttons } ], html: 'Testing' }); } });
