0

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>
Jon Wells
  • 4,191
  • 9
  • 40
  • 69

1 Answers1

0

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 ); 
txominpelu
  • 1,067
  • 1
  • 6
  • 11
  • Using the 1.0.1 RC does make a difference to the animation however the console reveals the following error "event.layerX and event.layerY are broken and deprecated in WebKit. They will be removed from the engine in the near future." – Jon Wells Apr 05 '12 at 12:28
  • Apparently that's a problem with the version of jquery. http://stackoverflow.com/questions/7825448/webkit-issues-with-event-layerx-and-event-layery Changing the jquery version from 1.6.4 to 1.7.1 removes this warning. – txominpelu Apr 05 '12 at 14:31
  • @CrimsonChin 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 properly to the buttons. Adding this small modification works: `4216a4217,4218 > e.setAttribute( "data-" + $.mobile.ns + "theme", o.theme ); > ` – txominpelu Apr 06 '12 at 23:58