-
26 Aug 2012 3:14 PM #1
Answered: n00b question -- But I need help with strings in itemTpl. Thanks!
Answered: n00b question -- But I need help with strings in itemTpl. Thanks!
I have a DataView list that I'm populating with a JSON file. I can't figure out how to pass the {photo} attribute into that "src" parameter in the <img> tag.Code:itemTpl: '<img src="{photo}" width="55" />
I know the model/store/json file are wired correctly, because this works properly.
Thanks all!Code:<div class="test">{thing}</div>
-
Best Answer Posted by gruese
amritsharma, is the photo attribute defined as a field in your model?
-
26 Aug 2012 5:13 PM #2
It looks correct. Aside from the fact that you forgot to closing ' at the end. You may want to add a height value and making sure the {photo} value contains the correct path.
-
28 Aug 2012 4:46 AM #3Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
- Answers
- 3102
Inspect the DOM to see what the <img> element looks like.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
28 Aug 2012 8:01 PM #4
This is the resulting HTML code with the img tag I get.
My {photo} attribute in the .json file contains a valid URL of a .jpg file one.Code:<img src width="55"> <div class="test">Cheese</div>
The "Cheese" text above is a value that's derived from the same .json file with {thing}.
Is {photo} a reserved keyword in Sencha? Maybe renaming it would help? But, im just speculating.
Thanks Michael.
P.S. I've learned so much from your answers on these forums that I recently picked up the MEAP of your upcoming book from Manning.
-
28 Aug 2012 8:02 PM #5
Sorry, in my actual code the quote is closed. I just copied and pasted a fraction of my code here. I should have made sure it's closed here too.
But, im still struggling with it.
-
28 Aug 2012 11:10 PM #6
amritsharma, is the photo attribute defined as a field in your model?
-
29 Aug 2012 6:34 AM #7


Reply With Quote