Min Lee
Min Lee

Reputation: 377

Ext JS 3.4 image refresh

I am using Ext JS 3.4 and whenever I open new windows with new source, the image remains the same. I logged src path and it changes every time but I have no clue why it keeps showing me the same image.

I have been looking up for hours but getCmp().getView().refresh() or any functions that seem related to this problem are not included in 3.4 .

var image = new Ext.BoxComponent({
    autoEl: {
        tag: 'img',
        width: 90,
        height: 250,
        src: img_path
    }
});

I made it like this and tried to open it in

new_win = new Ext.Window( ... );

(more specifically in side of vbox). I checked several times the image.autoEl.src has been updated but new_win keeps showing me first image shown before. Can anyone give me the solution or at least any kind of advice?

Upvotes: 1

Views: 545

Answers (2)

Fabio Barros
Fabio Barros

Reputation: 1439

See if that helps, first, give it an ID to your autoEl

autoEl: {
    tag: 'img',
    id: 'myImage',
    width: 90,
    height: 250,
    src: img_path
}

And then use the DOM to change the image

function setImage(new_image) {
    document.getElementById('myImage').src = new_image;
}

Upvotes: 0

Hesam Faridmehr
Hesam Faridmehr

Reputation: 1196

Problem is browser caching. Browsers by default cache all resources in GET requests

ExtJS has a config on connections to disable caching that adds a unique cache-buster param to GET requests

It's better to add unique parameter to img_path

Code should be like

autoEl: {
            tag: 'img',
            width: 90, 
            height: 250, 
            src: Ext.urlAppend(img_path, '_dc=' + (new Date().getTime())) 
        }

Upvotes: 1

Related Questions