如何绑定到jquery-mobile pagebeforeload事件? [英] how to bind to jquery-mobile pagebeforeload event?

查看:96
本文介绍了如何绑定到jquery-mobile pagebeforeload事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我迫不及待地试图让jquery mobile pagebeforeload 事件发生。这没有任何作用:

I'm getting desperate trying to get the jquery mobile pagebeforeload event to fire. This just does nothing:

 $(document).on("pagebeforeload", function( e, data ) {
        console.log("hello");
    });

根据 JQM docs ,语法正确。但是,没有任何反应。 Anybode可以告诉我为什么会这样吗?

According to the JQM docs, the syntax is correct. Still, nothing happens. Can anybode tell me why that is?

感谢您的帮助!

推荐答案

确保你包含 preventDefault(); 否则,它会快乐地继续加载。

Make sure you're including preventDefault(); Otherwise, it'll just merrily continue loading.

文档: http://jquerymobile.com/ demos / 1.1.0 / docs / api / events.html

$( document ).bind( "pagebeforeload", function( event, data ){

    // Let the framework know we're going to handle the load.

    event.preventDefault();

    // ... load the document then insert it into the DOM ...
    // at some point, either in this callback, or through
    // some other async means, call resolve, passing in
    // the following args, plus a jQuery collection object
    // containing the DOM element for the page.

    data.deferred.resolve( data.absUrl, data.options, page );

});

这篇关于如何绑定到jquery-mobile pagebeforeload事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆