How to change flip toggle switch value without triggering change event?
HTML
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.js"></script>
</head>
<html>
<body>
<div id="home" data-role="page">
<div data-role="header">
<H1>Home</H1>
</div>
<div data-role="content">
<a href="#page1" data-role="button">Go to page 1</a>
</div>
</div>
<div id="page1" data-role="page">
<div data-role="header">
<H1>page1</H1><a href="#home">Home</a>
</div>
<div data-role="content">
<h1>The init state is "ON"</h1>
<select id="myToggleSwitch" name="myToggleSwitch" data-role="slider">
<option value="GTA V" selected="true">ON</option>
<option value="GTA IV">OFF</option>
</select>
<h1 id="notification"></h1>
</div>
</div>
</body>
</html>
JavaScript
$(document).ready( function(){
$('#page1').bind('pageshow', function() { //to execute each time Home Page is shown
$('#myToggleSwitch').unbind('change');
$("#notification").html('');
var myNewValue = 'GTA IV';
$('#myToggleSwitch').val(myNewValue).slider("refresh");
$('#myToggleSwitch').bind('change', function() {
$("#notification").append('change event detected with this value: ' + jQuery(this).val() + '<BR>');
});
});
});