2012-02-11 29 views
2

在ExtJs中,我們有一個名爲Ext.onReady()的頁面加載事件,它在window.onload之後被調用,因爲它被註冊爲onload而不是被調用。所以基本上我們可以找到的最後一個事件是Ext.onReady()ExtJs想要在Ext.onReady()函數後調用一些代碼

的問題是,我有一個經營業務reqiurment這是我們無法改變的幾個Ext.onReady()。我有ExtJs TabbedPanel,它已被重新排列到頁面的最後Ext.onReady()頁面。

我想這是什麼渲染到頁面後登記在TabbedPanel一些事件。假設你沒有在TabbedPanel的渲染事件控制,以及你無法在這個網頁的最後onReady後創建onReady

+1

。所以你可以檢查面板是否呈現:'if(tabbedPanel.rendered){doSth(); }其他{tabbedPanel.on('afterrender',doSth); }' – Krzysztof 2012-02-12 12:21:09

+0

我已經考慮過你的選項作爲第一優先級,但在我的情況下選項卡面板它自己被渲染在Ext.onReady()!而且我沒有控制在tabbedPanel代碼之後寫任何東西。似乎starnge,但它是....(如果你知道關於savvion !!)。 – 2012-02-14 05:16:54

+0

您可以一直延遲創建'onReady',或者檢查間隔中的標籤面板。我沒有看到任何更好的解決方案,因爲沒有其他方法可以確保呈現所有內容。 – Krzysztof 2012-02-14 07:48:29

回答

0

感謝您的回信的朋友。我已經解決了這個問題。對於您的信息,併爲您的信息M發佈的解決方案

我已經創建了Java中的一個回調方法。這意味着它將被稱爲從其他功能被稱爲。我只是檢查了哪些功能需要花費大量時間來完成,並且最後還是創建了回調函數。如果你想添加事件到`TabbedPanel`我認爲你可以參考這個面板

問題就解決了感謝.. :)

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); 
}; 
}); 
相關問題