jquery-ui/demos/datepicker/icon-trigger.html
Felix Nagel 38101a478b Datepicker: Fix icon trigger demo
Support keyboard control. Fix close on second click.
Add removal notice.
2015-09-10 23:21:23 +02:00

42 lines
1.1 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Icon trigger</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
<script src="../../external/requirejs/require.js"></script>
<script src="../bootstrap.js">
var allowOpen = false,
datepicker = $( "#datepicker" ).datepicker({
beforeOpen: function() {
return allowOpen;
},
open: function() {
allowOpen = false;
}
} ),
widget = datepicker.datepicker( "widget" );
$( "<a href='#'>")
.append( "<img src='images/calendar.gif' tabindex='0' alt='Open Datepicker'>" )
.insertAfter( datepicker )
.on( "click", function( event ) {
allowOpen = true;
if ( widget.is( ":hidden" ) ) {
datepicker.focus();
}
event.preventDefault();
});
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker"></p>
<div class="demo-description">
<p>Click the icon next to the input field to show the datepicker. This demo will be removed soon since its promoting bad practice. Please see our migration guide.</p>
</div>
</body>
</html>