2012-02-11 1 views
2

ExtJsには、Ext.onReady()という名前のページロードイベントがあり、それはwindow.onloadの後に呼び出され、onloadに登録されて呼び出されます。我々が見つけることができるように基本的に最後のイベントはExt.onReady()です。ExtJsはExt.onReady()関数の後にいくつかのコードを呼び出したい

問題は私が変更できないビジネスのためにいくつかあります。ページの最後のExt.onReady()にあるページにリダイレクトされているExtJs TabbedPanelがあります。

私が欲しいのは、ページにレンダリングされた後、TabbedPanelにいくつかのイベントを登録することです。 TabbedPanelのレンダリングイベントを制御できず、onReadyのページの最後にonReadyを作成できないとします。

+1

あなたは私はあなたがこのパネルへの参照を取得できることを前提とし 'TabbedPanel'にイベントを追加したい場合。したがって、パネルがレンダリングされているかどうかを確認することができます: 'if(tabbedPanel.rendered){doSth(); } else {tabbedPanel.on( 'afterrender'、doSth); } ' – Krzysztof

+0

私はあなたのオプションを最優先事項と考えていましたが、私の場合はタブパネルで、それはExt.onReady()上でレンダリングされました!!私はそのtabbedPanelコードの後に​​何も書いていない。それは...(あなたが精霊について知っていれば!!)。 –

+0

いつでも 'onReady'を少し遅れて作成したり、間隔のあるタブ付きパネルをチェックしたりすることができます。すべてがレンダリングされることを保証する他の方法がないので、私はこれ以上の解決策は見当たりません。 – Krzysztof

答えて

0

返信いただきありがとうございます。私は問題を解決しました。あなたの情報とあなたの情報投稿ソリューションのために

私はJavaでコールバックメソッドを作成しました。これは、それが呼び出されることを意味するperticular他の関数と呼ばれています。私はちょうどその時間をかけて機能をチェックし、その機能の最後にコールバックを作成しました。

問題のおかげで解決します。.. :)

1
Ext.require([ 
'Ext.window.MessageBox', 
'Ext.tip.*' 
]); 

Ext.onReady(function(){ 
Ext.get('mb1').on('click', function(e){ 
    Ext.MessageBox.confirm('Confirm', 'Are you sure you want to do that?', showResult); 
}); 

Ext.get('mb2').on('click', function(e){ 
    Ext.MessageBox.prompt('Name', 'Please enter your name:', showResultText); 
}); 

Ext.get('mb3').on('click', function(e){ 
    Ext.MessageBox.show({ 
     title: 'Address', 
     msg: 'Please enter your address:', 
     width:300, 
     buttons: Ext.MessageBox.OKCANCEL, 
     multiline: true, 
     fn: showResultText, 
     animateTarget: 'mb3' 
    }); 
}); 

Ext.get('mb4').on('click', function(e){ 
    Ext.MessageBox.show({ 
     title:'Save Changes?', 
     msg: 'You are closing a tab that has unsaved changes. <br />Would you like to save your changes?', 
     buttons: Ext.MessageBox.YESNOCANCEL, 
     fn: showResult, 
     animateTarget: 'mb4', 
     icon: Ext.MessageBox.QUESTION 
    }); 
}); 

Ext.get('mb6').on('click', function(){ 
    Ext.MessageBox.show({ 
     title: 'Please wait', 
     msg: 'Loading items...', 
     progressText: 'Initializing...', 
     width:300, 
     progress:true, 
     closable:false, 
     animateTarget: 'mb6' 
    }); 

    // this hideous block creates the bogus progress 
    var f = function(v){ 
     return function(){ 
      if(v == 12){ 
       Ext.MessageBox.hide(); 
       Ext.example.msg('Done', 'Your fake items were loaded!'); 
      }else{ 
       var i = v/11; 
       Ext.MessageBox.updateProgress(i, Math.round(100*i)+'% completed'); 
      } 
     }; 
    }; 
    for(var i = 1; i < 13; i++){ 
     setTimeout(f(i), i*500); 
    } 
}); 

Ext.get('mb7').on('click', function(){ 
    Ext.MessageBox.show({ 
     msg: 'Saving your data, please wait...', 
     progressText: 'Saving...', 
     width:300, 
     wait:true, 
     waitConfig: {interval:200}, 
     icon:'ext-mb-download', //custom class in msg-box.html 
     animateTarget: 'mb7' 
    }); 
    setTimeout(function(){ 
     //This simulates a long-running operation like a database save or XHR call. 
     //In real code, this would be in a callback function. 
     Ext.MessageBox.hide(); 
     Ext.example.msg('Done', 'Your fake data was saved!'); 
    }, 8000); 
}); 

Ext.get('mb8').on('click', function(){ 
    Ext.MessageBox.alert('Status', 'Changes saved successfully.', showResult); 
}); 

//Add these values dynamically so they aren't hard-coded in the html 
Ext.fly('info').dom.value = Ext.MessageBox.INFO; 
Ext.fly('question').dom.value = Ext.MessageBox.QUESTION; 
Ext.fly('warning').dom.value = Ext.MessageBox.WARNING; 
Ext.fly('error').dom.value = Ext.MessageBox.ERROR; 

Ext.get('mb9').on('click', function(){ 
    Ext.MessageBox.show({ 
     title: 'Icon Support', 
     msg: 'Here is a message with an icon!', 
     buttons: Ext.MessageBox.OK, 
     animateTarget: 'mb9', 
     fn: showResult, 
     icon: Ext.get('icons').dom.value 
    }); 
}); 

function showResult(btn){ 
    Ext.example.msg('Button Click', 'You clicked the {0} button', btn); 
}; 

function showResultText(btn, text){ 
    Ext.example.msg('Button Click', 'You clicked the {0} button and entered the text "{1}".', btn, text); 
}; 
}); 
関連する問題