【问题标题】:Mimic window load event in Jquery mobile在 Jquery mobile 中模拟窗口加载事件
【发布时间】:2012-01-31 11:06:15
【问题描述】:

我需要拉取图像的宽度,这只能在窗口加载事件之后进行。

当然,这不会在 jQuery Mobile 中触发,所以我需要一个等效的。

我有:

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

当不通过 AJAX 加载时,它显然可以正常工作,但我已经循环了 Jquery Mobile 提供的各种事件,但我无法让它返回正确的值。

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

本质上它需要返回新加载页面上图像的宽度。

【问题讨论】:

    标签: javascript jquery events jquery-mobile jquery-events


    【解决方案1】:

    pageLoad 事件。

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

    需要连接起来

    【讨论】:

    • 您需要将事件绑定到函数。这一切都在我链接到的文档中。
    • 正如我在问题中所暗示的那样,我已经使用实时和绑定方法循环了 jQuery Mobile 提供的事件。没有欢乐
    • 绑定到元素而不是我提供的链接第一段中概述的文档。例如,请参见页面底部
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-25
    • 2017-06-10
    • 1970-01-01
    • 2022-06-13
    • 2015-08-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多