简体   繁体   English

sencha touch 2中的javascript on(“加载”)

[英]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?. 我在sencha touch 1.1版本中有此代码,如何使其在版本2中工作? "load" is not working “加载”不起作用

Html: 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 不推荐使用on(): http//docs.sencha.com/touch/2-0/#!/api/Ext.EventManager-method-on

Thanks! 谢谢!

load is not a property for image component in ST2. load 不是 ST2中image组件的属性 It's an event that will be fired when image is loaded. 加载图片后会触发此event

So, you need to listen for load event of image component in Sencha Touch 2. 因此,您需要在Sencha Touch 2中listen image组件的load事件。

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... 我在Sencha上没有太多经验,但是我想应该是这样的……

// 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() {    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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