Jquery Mobile Hyperlink-button Animation Not Firing

不打扰是莪最后的温柔 提交于 2019-12-12 03:02:39

问题


I have two JQM buttons:

  <a id="clearA" href="#" data-role="button">Clear a</a>
  <a id="clearB" href="#mainPage" data-role="button">Clear b</a>

And I am wiring up the click event for (hyperlink/button "clearA") like this:

$("#clearA").click(function (e) {
    e.stopImmediatePropagation();
    e.preventDefault();
    console.log("Me? I got clicked");
});

When I click "clearA" the event is fired but the button doesn't show its pressed animation/state. If I click the non wired up button "clearB", the button animates.

Why doesn't button "clearA" animate?

UPDATE I am using JQM 1.1.0

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script>

回答1:


Running this code with the latest version of jquery mobile taken from the cdn both buttons work exactly in the same way, Can you try using the following version to see if it works for you?

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>

UPDATED:

JQM 1.1 is still an unstable version and it has some rough edges. Using that version none of the buttons work properly for me and it seems to be because the library doesn't assign the theme data attribute properly to the buttons.

Adding this small modification (in diff format) works:

4216a4217,4218 > e.setAttribute( "data-" + $.mobile.ns + "theme", o.theme ); 


来源:https://stackoverflow.com/questions/10027441/jquery-mobile-hyperlink-button-animation-not-firing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!