1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    8
    Vote Rating
    0
    amritsharma is on a distinguished road

      0  

    Default Answered: n00b question -- But I need help with strings in itemTpl. Thanks!

    Answered: n00b question -- But I need help with strings in itemTpl. Thanks!


    Code:
      itemTpl: '<img src="{photo}" width="55" />
    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.

    I know the model/store/json file are wired correctly, because this works properly.
    Code:
    <div class="test">{thing}</div>
    Thanks all!

  2. amritsharma, is the photo attribute defined as a field in your model?

  3. #2
    Sencha User
    Join Date
    Jul 2012
    Posts
    148
    Vote Rating
    9
    Answers
    12
    pentool will become famous soon enough

      0  

    Default


    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.

  4. #3
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    34,107
    Vote Rating
    453
    Answers
    3155
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    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.

  5. #4
    Sencha User
    Join Date
    Aug 2012
    Posts
    8
    Vote Rating
    0
    amritsharma is on a distinguished road

      0  

    Default


    This is the resulting HTML code with the img tag I get.
    Code:
    <img src width="55">
    <div class="test">Cheese</div>
    My {photo} attribute in the .json file contains a valid URL of a .jpg file one.
    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.

  6. #5
    Sencha User
    Join Date
    Aug 2012
    Posts
    8
    Vote Rating
    0
    amritsharma is on a distinguished road

      0  

    Default


    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.

  7. #6
    Sencha User
    Join Date
    Aug 2012
    Posts
    17
    Vote Rating
    1
    Answers
    2
    gruese is on a distinguished road

      1  

    Default


    amritsharma, is the photo attribute defined as a field in your model?

  8. #7
    Sencha User
    Join Date
    Aug 2012
    Posts
    8
    Vote Rating
    0
    amritsharma is on a distinguished road

      0  

    Default


    Thanks!