-
9 Dec 2011 9:30 PM #1
Image in PR3: cannot set width or height
Image in PR3: cannot set width or height
I have a login panel with a logo that loaded correctly in PR2. When I load it using PR3, I get:
Uncaught TypeError: Cannot call method 'setWidth' of undefined. (all-debug line 38922)
If I replace the width and height for the image panel with "flex:1" then the page and the image panel renders, but with zero width.
Code:Ext.define('VUMobile.view.Home', { extend: 'Ext.form.Panel', xtype: 'homepanel', id:'loginForm', config: { title: 'Account', padding:12, iconCls: 'home', cls: 'home', layout:{ type:'vbox', align:'middle' }, items:[ { xtype: 'image', src: 'js/mobile/resources/images/logo.png', width:300, height:124 }, { xtype:'panel', flex:1, items:[ { xtype:'fieldset', title:'Login', id:'loginFieldSet', items:[{ xtype:'textfield', name:'username', label:'Username', value:(localStorage.getItem("VUMobile.username") || ""), labelWidth:'40%' },{ xtype:'passwordfield', name:'password', label:'Password', labelWidth:'40%' }] }, { xtype: 'button', ui: 'confirm', text: 'Log in', action: 'loginUser' } ] } ] } });
-
9 Dec 2011 11:28 PM #2
Thanks for the report.
Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
10 Dec 2011 6:09 AM #3
Hi, thank you for report this.
Waiting for an official fix for this issue, I suggest you to override the Ext.Img component as follow:
This will allow you to use the Img component inside your application.Code:Ext.Img.override({ doSetWidth: function(width) { if (this.getMode() === 'background') { this.element.dom.style.width = width + 'px'; }else{ this.imageElement.setWidth(width); } }, doSetHeight: function(height) { if (this.getMode() === 'background') { this.element.dom.style.height = height + 'px'; }else{ this.imageElement.setHeight(height); } }, destroy: function() { if(this.imageElement){ this.imageElement.destroy(); } this.callParent(); } });
Hope this helps.Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata
-
14 Dec 2011 10:34 AM #4Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,659
- Vote Rating
- 14
This has been fixed for the next release.
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-1214
in
2.0.


Reply With Quote