0
我需要找出動態創建的容器的絕對位置,它們被添加到面板中。ExtJS:獲取動態容器的絕對位置
var activityContainer = Ext.create('Ext.Container', {
html: activityName,
width: ACTIVITY_WIDTH,
height: ACTIVITY_HEIGHT,
margin: topMargin + ' 0 0 0',
cls: 'activity',
listeners: {
render: function() {
this.getEl().dom.title = 'Name: ' + activity.name + reqQuicktip;
},
afterrender: function() {
console.log('Y: ' + this.getEl().getTop() +' X: '+ this.getEl().getLeft())
}
}
})
tradePanel.add(activityContainer);
我已經知道,只有當容器已經被渲染時,我才能得到位置。因此我使用afterrender監聽器。方法getY()/ getTop()等不能按我期望的方式工作。我總是得到1我的x座標和沒有足夠的y座標。
我在這裏失蹤了什麼?
謝謝!
好吧。我已經這樣實現了,但仍然得到了相同的結果。 – Legenzoo 2014-11-06 20:56:00
你認爲你可以提供一個小問題,所以我可以看看? – 2014-11-06 20:57:37
https://fiddle.sencha.com/#fiddle/d01 我意識到我得到的位置相對於面板中的最後一項,但不是絕對的。 = / – Legenzoo 2014-11-07 01:45:41