senchalabs / jQTouch

Create powerful mobile apps with just HTML, CSS, and Zepto.js (or jQuery).
http://www.jqtouch.com/
MIT License
2.78k stars 589 forks source link

Triggering transitions fails #489

Closed emepyc closed 11 years ago

emepyc commented 11 years ago

Hi,

I am trying to fire a transition on a non-link element (not a <a>). I have written a test for this, something like:

<!DOCTYPE html> <meta charset="utf-8"> <html> <head> <!-- Local jqTouch --> <link rel="stylesheet" href="lib/jqtouch-1.0-b4-rc/themes/css/apple.css" title="jQTouch"> <!-- <style type="text/css" media="screen">@import "lib/jqtouch-1.0-b4-rc/themes/css/jqtouch.css";</style> --> <script src="lib/jqtouch-1.0-b4-rc/src/lib/zepto.min.js" type="text/javascript" charset="utf-8"></script> <script src="lib/jqtouch-1.0-b4-rc/src/jqtouch.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript" charset="utf-8"> var jQT = new $.jQTouch({ }); </script>

</head> <body> <a id="goodLink2" href="#second" class="flip"></a> <div id="first"> <a id="goodLink" href="#second" class="flip">Go to second ++</a> <br/> <br/> <p id="myLink" class="flip touch">There we go ++</p> </div>

<div id="second"> <div class="toolbar"> <a class="button back" href="#">Back</a> </div> <p>Some Info</p> </div> <script>

$("#myLink").on("click", function() {alert("hi"); $("#goodLink").trigger("click")}); // $("#myLink").on("click", function() {alert("hi"); window.location.href="#second"});

</script> </body>

</html>

The above code works on (at least) Firefox, Chrome and Safari running on a desktop computer, but doesn't seem to work on mobile devices.

Am I missing something? (also, if there is a better way to achieve what I want, I would be very grateful of hearing it) M;

thomasyip commented 11 years ago

On mobile, try bind() and trigger() tap event.

Let me know if it doesn't solve your problem.