1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    36
    Vote Rating
    0
    flyingace is on a distinguished road

      0  

    Default Unanswered: How do I set an Img's src config dynamically?

    Unanswered: How do I set an Img's src config dynamically?


    My BirdPhoto class extends Ext.Panel and uses HTML in an XTemplate to specify the source for the photo of the bird. Since there is nothing else in this class, I would like to change my class so it extends Ext.Img instead. Whereas I am able to set the value of the src in the XTemplate as follows:
    HTML Code:
    <img src="resources/images/{birdPhotoURL}" />
    I can't use this same format when trying to define the src config for a class that extends Ext.Img and don't know how to indicate the dynamic value {birdPhotoURL}.

    Can anyone help me clear this up? Any help would be appreciated.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,632
    Answers
    3452
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    If you are going to use Ext.Img then you can use setSrc to change the src of the image.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    36
    Vote Rating
    0
    flyingace is on a distinguished road

      0  

    Default


    Could you elaborate on this please? Where would I use setSrc and how would I define the variable that is currently as {birdPhoto}? If it helps at all, here is the full class description at present:

    Code:
    Ext.define('Birds.view.detail.BirdPhoto', {
        extend: 'Ext.Button',
        xtype: 'birdphoto',
        id: 'birdPhoto',
        
        config: {
            minHeight: '170px',
            baseCls: 'birdPhoto',
            tpl: new Ext.XTemplate(
                '<img src = "resources/images/thumbs/{birdPhotoURL}" />'
            )
        }
    });
    For what it's worth, I would like to be able to use Ext.Img because then I could have it respond to a tap event. Perhaps there is another way around this. Is it possible to get a Panel to respond to a tap or similar event?

Thread Participants: 1