2
我用這個代碼,論壇上發現沒有4.0.2a錯誤,現在4.0.7給了我錯誤f是空,所以我檢查與螢火蟲,並發現爲什麼這個extjs代碼在extjs 4.0.7中返回null?
getIframe: function() {
return this.getTargetEl().child('iframe');
},
this.getTargetEl() .child('iframe')返回null
所以任何想法爲什麼這與4.0.7發生?
Ext.define('Ext.panel.iframePanel', {
extend : 'Ext.panel.Panel',
alias : 'widget.iframePanel',
src : 'about:blank',
loadingText : 'Loading ...',
loadingConfig : null,
renderTpl: [
'<div class="{baseCls}-body<tpl if="bodyCls"> {bodyCls}</tpl><tpl if="frame"> {baseCls}-body-framed</tpl><tpl if="ui"> {baseCls}-body-{ui}</tpl>"<tpl if="bodyStyle"> style="{bodyStyle}"</tpl>>',
'<iframe src="{src}" width="100%" height="100%" frameborder="0"></iframe>',
'</div>'
],
initRenderData: function() {
return Ext.applyIf(this.callParent(), {
bodyStyle: this.initBodyStyles(),
bodyCls: this.initBodyCls(),
src: this.getSource()
});
},
initComponent: function() {
this.callParent(arguments);
this.on('afterrender', this.onAfterRender, this, {});
},
/**
* Gets the iframe element
*/
getIframe: function() {
return this.getTargetEl().child('iframe');
},
getSource: function() {
return this.src;
},
setSource: function(src, loadingText) {
this.src = src;
var f = this.getIframe();
if (loadingText || this.loadingText) {
this.body.mask(loadingText || this.loadingText);
}
f.dom.src = src;
},
resetUrl: function() {
var f = this.getIframe();
f.dom.src = this.src;
},
onAfterRender: function() {
var f = this.getIframe();
f.on('load', this.onIframeLoaded, this, {});
},
onIframeLoaded: function() {
if (this.loadingText) {
this.body.unmask();
}
}
});
var printpanel = Ext.create('Ext.panel.Panel', {
title : 'Print',
width : 800,
height : 300,
renderTo : Ext.getBody(),
bodyPadding : 5,
layout : 'fit',
items: Ext.widget('iframePanel', {
border : false,
src : '',
itemId : 'ds_print_panel'
}),
tbar: ['->',{
text : 'Test',
listeners: {
click: function(){
printpanel.down('#ds_print_panel').setSource("http://www.rockstown.com/node/4");
}
}
}]
});
非常感謝。仍在螢火蟲控制檯上拋出正文爲空錯誤 – 2012-01-12 10:05:05
我沒有這個錯誤。您可以將您的代碼與jsfiddle上的示例進行比較。 – Krzysztof 2012-01-12 10:42:47
是的,它只是我,即時通訊使用sanbox版本在我的網頁。似乎它不適用邊框:錯誤等。再次呈現模板感謝 – 2012-01-12 12:56:38