简体   繁体   English

jQuery Mobile中的模拟窗口加载事件

[英]Mimic window load event in Jquery mobile

I need to pull the width of images, which I can only do after the window load event. 我需要拉宽图像的宽度,这只有在窗口加载事件之后才能执行。

Of course, this doesn't fire in jQuery Mobile, so I need an equivalent. 当然,这不会在jQuery Mobile中触发,因此我需要一个等效的方法。

I have: 我有:

$(window).load(function(){
            var diff = $('div.canvas img.photo').get(1).width;
            console.log(diff);
        });

which obviously works fine when not loaded through AJAX, but I have cycled though the various events Jquery Mobile provides, and I can't get it to return the correct value. 当不通过AJAX加载时,这显然可以很好地工作,但是我循环了Jquery Mobile提供的各种事件,但是我无法使其返回正确的值。

$(document).live('pageshow', function(){
        var diff = $('div.canvas img.photo').get(1).width;
        console.log(diff);
    });

Essentially it needs to return the width of an image on a newly loaded page. 本质上,它需要返回新加载页面上图像的宽度。

pageLoad Event. pageLoad事件。

http://jquerymobile.com/demos/1.0.1/docs/api/events.html http://jquerymobile.com/demos/1.0.1/docs/api/events.html

Will need to wire it up though 虽然需要将其连接起来

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

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