PDA

View Full Version : help needed to find problem between 4.0.2a and 4.0.7 in this code



extremed
12 Jan 2012, 1:13 AM
Hi

I used this code which found on forum without errors in 4.0.2a and now 4.0.7 gives me error f is null so i checked with firebug and found out that


getIframe: function() {
return this.getTargetEl().child('iframe');
},

this.getTargetEl().child('iframe') is return null

so any idea why this happen with 4.0.7?

this is the example code

http://jsfiddle.net/Cu9DZ/



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");
}
}
}]
});

mitchellsimoens
12 Jan 2012, 9:47 AM
Have you tried down instead of child? child should only look for a direct child where down will keep going down the hierarchy until it finds a match or ends.

extremed
12 Jan 2012, 9:52 AM
yeah it works