I am using jqueryui for a dialog box. Clicking on the 'Click for a modal' link the first time works. When pressing the ESC
key, the dialog box disappears. But the clicks after that don't work. I want those to work as well. Refreshing the page makes everything OK.
HTML:
<a href="" class="click_me" style="font-size:15px;"> Click for a modal</a><br />
<div class="demo" ">
<div id="dialog" title=" Upload Your Profile Picture" style="border1111:1px solid red; width:640px;">
this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is this is
</div><!-- end of id dialog -->
</div><!-- End demo -->
jQuery snippet:
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(".click_me").bind('click', function (e) {
e.preventDefault();
$("#dialog").css('border', '5px solid #848484');
$("#dialog").dialog({
width: 460
});
//$( "#dialog" ).dialog( "option", "height", 180 );
});
$("body").bind("keyup#dialog", function (event) {
// 27 == "esc"
if (event.which == 27) {
// TODO: close the dialog
// unbind the event
$("body").unbind("keyup.myDialog");
}
});
});
</script>
How can I make multiple clicks work?
See Question&Answers more detail:os