jQuery   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jQuery mobile mobileinit没有被触发大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在jQuery mobile加载之前通过 AJAX动态加载页面内容,所以我试图使用mobileinit事件.但它没有用.这是我的代码请帮忙

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <Meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <Meta name="viewport" content="width=device-width,initial-scale=1">

    <link rel="stylesheet" href="http://jquerymobile.com/demos/1.3.0-beta.1/css/themes/default/jquery.mobile-1.3.0-beta.1.css" />
    <script src="js/jquery-1.8.2.min.js"></script>
    <script>
        $(document).bind("mobileinit",function()  {        
            $("#notification").text("Please enter your domain name.");
        });
    </script>
    <script src="js/jquery.mobile-1.3.0.min.js"></script>
    <title>Insert title here</title>
    </head>
    <body>
       <h3 id="notification" style="font-family: fantasy; color: red; text-align: center;"></h3>
    </body>
    </html>

解决方法

这不行.

触发mobileinit事件时,DOM内容仍为空. Pageinit是第@L_674_8@你甚至可以虑这样做的事件.但更好的是pagebeforeshow事件.

$(document).on('pagebeforeshow','#index',function(){    

});

这是我添加动态生成内容的旧示例:http://jsfiddle.net/Gajotres/GnB3t/

这是另@L_674_8@例子,只需单击下一步按钮即可查看动态生成页面http://jsfiddle.net/Gajotres/8jcGb/

大佬总结

以上是大佬教程为你收集整理的jQuery mobile mobileinit没有被触发全部内容,希望文章能够帮你解决jQuery mobile mobileinit没有被触发所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。