-
26 Feb 2008 12:43 AM #1
FormPanel > Panel > IMG, ie7 error
FormPanel > Panel > IMG, ie7 error
Hello ExtJSers!
I've created a FormPanel and needed to embedd an IMG element in it (upload image preview).
So I did it like this:
and put 'img_panel' in Ext.FormPanel's [items].Code:var img_preview = document.createElement('img') img_preview.width = 156 img_preview.width = 118 img_preview.src = 'http://www.tapuz.co.il/HP/images/wakingup.jpg' var img_panel = new Ext.Panel({ items:[new Ext.Element(img_preview)] })
It works in firefox but gives me the following error in explorer 7:
Line: 15658
Error: Unexpected call to method or property access.
on this line:
fromCode:this[name] = Ext.get(pnode.appendChild(el));
[name == 'bwrap']Code:createElement : function(name, pnode){
from
So, is this the right way to embedd an image in a FormPanel? What am I missing?Code:Ext.Panel = Ext.extend(Ext.Container, {
Thanks,
michael
-
26 Feb 2008 1:14 AM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 44
Use:
Code:var img_panel = new Ext.Panel({ items:[{ xtype: 'box', autoEl: {tag: 'img', height: 118, width: 156, src: 'http://www.tapuz.co.il/HP/images/wakingup.jpg'} }] })
-
26 Feb 2008 1:38 AM #3
-
10 Mar 2008 9:57 AM #4
Hi Condor,
I have similar problem, but I need to assign the image element to a variable so that I can change the image source later. My code now, is like the following:
this._window = new Ext.Window({
layout:'fit',
width:400,
height:200,
closeAction:'hide',
plain: true
});
var Img = new Ext.Element(document.createElement('img'));
this._window.add(Img);
Img.on('load',this.MyMethod,this);
....
Img.src = myvar;
But when I add the Img element I get same posted error (in IE7).
Some suggestion?
-
10 Mar 2008 11:09 PM #5Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 44
You can't add an Element to an Ext.Container (e.g. Ext.Window). You can only add Ext.Components.
Use:
Code:this._window = new Ext.Window({ layout:'fit', width:400, height:200, closeAction:'hide', plain: true }); var img = new Ext.BoxComponent({ autoEl: {tag: 'img', src: Ext.BLANK_IMAGE_URL}, listeners: { render: function(c) { c.getEl().on('load', this.MyMethod, this); }, scope: this } }); this._window.add(img); .... img.getEl().dom.src = myvar;
-
12 Mar 2008 2:50 AM #6
-
17 Sep 2011 8:21 AM #7
Thanks Condor, had the same problem in IE 8 using Ext 3.3.1 and defining the image as Ext.BoxComponent fixed it.


Reply With Quote