1. #1
    Sencha User
    Join Date
    Sep 2007
    Posts
    91
    Answers
    7
    Vote Rating
    2
    tm8747a is on a distinguished road

      0  

    Default Answered: How to update layout when changing an image

    Answered: How to update layout when changing an image


    I have an Ext.window.Window component with a form in it that has a vbox layout. Inside that vbox, one of the items is an Ext.Img component. After a certain operation, I need to change the image, which I do by calling the setSrc() method. The image updates fine, but if it's bigger or smaller, the layout doesn't update. I tried calling doLayout() and updateLayout() on the window component, the form, the vbox container, none of it works. Any idea how I can get the layout to update properly?

  2. I believe what you'll need to do is first set a load listener on the imgEl (include single: true to have this happen just the one time you load the new src) that says once the image src is loaded to the page have the parent container doLayout().

    Alternatively, if you know the new source's dimensions set the height/width and then setSrc().

  3. #2
    Sencha User
    Join Date
    Sep 2007
    Posts
    91
    Answers
    7
    Vote Rating
    2
    tm8747a is on a distinguished road

      0  

    Default


    I also tried doing doComponentLayout(), doesn't work. I actually ran a test where I call doLayout(), doComponentLayout(), and updateLayout() on all the containers/components that supported each of those (including the Ext.Img component, which I didn't mention in first post) just to see if a combination would work, but even that got me no result.

  4. #3
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    4,895
    Answers
    368
    Vote Rating
    176
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      0  

    Default


    I believe what you'll need to do is first set a load listener on the imgEl (include single: true to have this happen just the one time you load the new src) that says once the image src is loaded to the page have the parent container doLayout().

    Alternatively, if you know the new source's dimensions set the height/width and then setSrc().

  5. #4
    Sencha User
    Join Date
    Sep 2007
    Posts
    91
    Answers
    7
    Vote Rating
    2
    tm8747a is on a distinguished road

      0  

    Default


    Quote Originally Posted by slemmon View Post
    I believe what you'll need to do is first set a load listener on the imgEl (include single: true to have this happen just the one time you load the new src) that says once the image src is loaded to the page have the parent container doLayout().
    You, sir, are the very definition of a genius. Using the load listener did it. For others who may run into this, here's the exact code I used, bearing in mind that the load event is actually for the image DOM element whereas I'm setting up an image component:

    Code:
    this.control({
        '#myImgComponent': {
            render: function(img) {
                img.getEl().on('load', function() {
                    img.ownerCt.doLayout();
                });
            }
        }
    });

  6. #5
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    4,895
    Answers
    368
    Vote Rating
    176
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      0  

    Default


    Thanks for sharing your code/successes with others! I do like seeing that on the forums.

    BTW, not a genius. Ran into the same problem myself right when the image component came out and I asked the question on the forums.

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi