【问题标题】:Debugging jquery mobile on Eclipse在 Eclipse 上调试 jquery mobile
【发布时间】:2012-02-05 18:13:30
【问题描述】:

所以我正在学习 jQuery Mobile,并尝试在我的 Android 模拟器中运行以下代码。我试图做的是使用 $.mobile.changePage() 方法导航到我的联系人页面(contact.html)。显然我做错了什么,因为我什至没有看到我在 JS 中放置的 alert() 调用。

我在我的 html 文件中使用 jquery.mobile-1.0.min.css、jquery-1.6.4.min.js 和 jquery.mobile-1.0.min.js。

我的代码中有一个 id 为“html5Btn”的 html5 按钮标签。我已将该按钮包装在带有 data-role='content' 属性的“div”中。

谁能解释一下...

  1. 我在代码中做错了什么?
  2. 如何在 Eclipse 中调试 JS?我在我的 LogCat 中没有看到任何错误?这是我寻找 jQuery 错误的地方吗?

    //CHANGE PAGE USING changePage()...placed this code 
    $("#html5Btn").bind('click', function(event) {
        alert("in JS");
        $.mobile.changePage('contact.html');
    }, false);
    

【问题讨论】:

    标签: eclipse jquery-mobile


    【解决方案1】:

    试试

    //CHANGE PAGE USING changePage()...placed this code 
    $("#html5Btn").live('click', function(event) {
        alert("in JS");
        $.mobile.changePage('contact.html');
    }, false);
    

    对于调试,firebug 是你的朋友!另外,我正在使用 intellij 11 Ultimate...我必须说 javascript 调试器很好!

    【讨论】:

    • 所以当你尝试使用 jQuery mobile 为 Android 平台开发一些东西时,你在 Firebug 中调试并在 Eclipse 中编码?
    • 不,我在 intellij 中编辑并使用它的 javascript 调试器在 firefox 和 chrome 中进行本地调试。我偶尔也会使用萤火虫......这取决于我在做什么。对于 android 我使用 sdk 的 adb 工具来查看控制台。我刚开始研究这个以进行 android 调试。 jsconsole.com/remote-debugging.html
    • 谢谢你的工作,这让我问为什么“.live()”工作而不是“.bind()”甚至“.click()”
    • 我的猜测是,当执行绑定的 jquery/javascript 代码执行时,#html5Btn 不在 dom 中。看看这个alfajango.com/blog/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-29
    • 2021-09-21
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 2013-12-10
    相关资源
    最近更新 更多