PDA

View Full Version : How to use setHTML ?



Elfayer
12 Jul 2012, 11:30 PM
Hi,
I tried that :


'#gridSetting': {
itemclick: function (grid, item) {
background = item.data.wal_path;
var img = Ext.ComponentQuery.query('#preview')[0];
img.setHTML('<img src="' + background + '" width="100%", height="100%"/>');
}
}

And it's not working.

Farish
13 Jul 2012, 12:01 AM
try using 'update' instead. That works for me.

Elfayer
13 Jul 2012, 12:10 AM
No for me... I don't understand it should work.

Farish
13 Jul 2012, 12:17 AM
try debugging with Firebug. See if these two variables (background and img) are getting the right values:



background = item.data.wal_path;
var img = Ext.ComponentQuery.query('#preview')[0];

evant
13 Jul 2012, 12:20 AM
setHTML only applies to elements, you're trying to call it on a component.

Also, setHTML updates the innerHTML of the node, so even if setHTML worked it's not what you want.



background = item.data.wal_path;
var img = Ext.ComponentQuery.query('#preview')[0];
img.setSrc(background);

Elfayer
13 Jul 2012, 12:28 AM
Yes that's working, but in fact i wanted to use the html to put the background on full screen.
Because the panel where i want to put a background has an absolute layout. (and i can't change it)

EDIT: It's ok, i've put that on the panel:

items: new Ext.Img({ itemId: 'background' , height: '100%', width: '100%'})