Trigger delayed event from button
Description
The following code shows how to trigger delayed event from button.
Example
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://code.jquery.com/jquery-2.0.0.js'></script>
<script type='text/javascript'
src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script>
<link rel="stylesheet" type="text/css"
href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css">
</head><!--from ww w . j av a 2 s . c o m-->
<body>
<div data-role="page" id="p1">
<div data-role="header">
<h1>Header Page 1</h1>
<a href="#p2" data-role="button" onclick="save()">Go To Page 2</a>
</div>
<div data-role="content">content</div>
</div>
<div data-role="page" id="p2">
<div data-role="header" data-rel="back">
<h1>Header Page 2</h1>
<a href="#p1" data-role="button">Go To Page 1</a>
</div>
<div data-role="content">content</div>
</div>
<script type='text/javascript'>//<![CDATA[
$(document).bind('pagebeforechange', function(e, data) {
console.log("pagebeforechange");
});
function save() {
setTimeout(function(){
console.log("save trigger");
},3000)
};
//]]>
</script>
</body>
</html>