简体   繁体   中英

javascript on(“load”) in sencha touch 2

I have this code in version sencha touch 1.1, how to make it works in Version 2?. "load" is not working

Html:

<img src="" id="previewImage"/>

Code:

this.domImage=Ext.get("previewImage");
this.domImage.on("load",function(){
    debugger; // not working
    a.sizePhotoInContainer();
    a.resizePhoto()
});

on() was deprecated: http://docs.sencha.com/touch/2-0/#!/api/Ext.EventManager-method-on

Thanks!

load is not a property for image component in ST2. It's an event that will be fired when image is loaded.

So, you need to listen for load event of image component in Sencha Touch 2.

Do it like this,

var img = Ext.create('Ext.Img', {
    src: 'http://www.sencha.com/assets/images/sencha-avatar-64x64.png',
    height: 64,
    width: 64,
    listeners : {
        load : function {
          // ....
          // ....
          // ....
        }
    }
});

I don't have much experience with Sencha, but I think it would be something like this...

// create image
var img = Ext.create('Ext.Img', {
    src: 'http://www.sencha.com/example.png'
});
// callback on load
img.load = function() {
}

Or

var img = Ext.create('Ext.Img', {
    src: 'http://www.sencha.com/example.png',
    load : function() {    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM