Preventing a button in a form from submitting the form
This is to demonstrate that a button located in a form is always submitting the form.
by Yakov
HTML
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.css">
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.js"></script>
<div id="home" data-role="page">
<div data-role="header">
<H1>Home</H1>
</div>
<div data-role="content">
<a href="#formPage" data-role="button">Go to the form</a>
</div>
</div>
<div id="formPage" data-role="page">
<div data-role="header">
<H1>Form Page</H1>
</div>
<div data-role="content">
<form method="GET" action="http://deal.yakov66.ru/abcp/search" id="myForm" >
<input type="text" id="myTextInput" value="some input"/>
<button class="mySubmit" type="submit">Submit1</button>
</form>
</div>
</div>
JavaScript
$(".mySubmit").click(function(event){
alert(this.form.id);
event.preventDefault();
});