Im new in jQuery so sure that i am doing something wrong :(. Matter is that i have a main page:
<html>
<head>
<title>My Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<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>
<div data-role="header">
<h1>My Title</h1>
</div><!-- /header -->
<div data-role="content">
<a href="pagina2.php">click me</a>
</div><!-- /content -->
inside this one I redirect to another page with a $(document).ready inside. the problem is that the “$(document).ready” doesn’t triggers until I manualy refresh the page, after this, everything works fine.
<html>
<head>
<title>My Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<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>
<script type="text/javascript" src="jquery.js"></script>
$(document).ready(function(){
$(“p”).click(function(){
$(this).hide();
});
});
<div data-role="header">
<h1>My Title</h1>
</div><!-- /header -->
<div data-role="content">
<p>If you click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>
</div><!-- /content -->
should I redirect whithout an href or maybe im doing something wrong ??
Pd: sorry for my inglish 🙂
With jQuery mobile secondary pages are loaded asynchronously and javascript in those pages will not be executed.
You should include all your javascript code in an external script and link that script in the head of your initial page.
btw; there is detailed info on all this in the docs see: http://jquerymobile.com/demos/1.1.0-rc.1/docs/pages/page-scripting.html