PDA

View Full Version : Jason data for Image URL



DesiTesh
10 Feb 2010, 10:44 AM
hi folks,

//Jason
var jSource = '{....,"image_file":"http://extjs.com/deploy/dev/examples/shared/screens/desktop.gif"},..



items: [{
columnWidth: .3,
border: false,
items: {
xtype:'box',
anchor:'',
isFormField:true,
fieldLabel:'Image',
autoEl:{
tag:'div', children:[{
tag:'img',
qtip:'Tooltip on the image',
src:'image_file'
}....

img src is displayed as text 'image_file' not taking taking actual data value from jason to display image URL.

hhanna
10 Feb 2010, 1:09 PM
It's displaying the string 'image_file' because that's what you've set as the source.

Likewise, if you did the following:

src: 'go eat bananas'The img's source would read as src='go eat bananas'

Unfortunately, you haven't posted enough code for anyone to see how you're trying to access your jSource variable. Also, it looks like jSource is a string--notice the leading and trailing quotes.
No doubt it is supposed to be a javascript object. If so, notice the notation below.


var jSource = {
image_file: 'http://extjs.com/deploy/dev/examples/shared/screens/desktop.gif'
}
Then you'd reference the jSource object's image_file property as:


tag:'img',
qtip:'Tooltip on the image',
src: jSource.image_file
If you mean to have jSource as a string, as if you're constructing your json object manually, then read up on Ext.encode() & Ext.decode().