colorbox close confirmation
$(document).ready(func开发者_如何学运维tion(){
$('#rest').colorbox();
$("#cboxClose").click(function(){ $.fn.colorbox.close(); });
var cboxClose = $.fn.colorbox.close;
$.fn.colorbox.close = function(){ if(confirm("Are you sure?")) { cboxClose(); } }
});
this code close my jquery colorbox when i confirm the dialog, but if i click on cancel (!confirm) its as closing
what im doing wrong?
I think this can be done a little simpler
$(function(){
$('#rest').colorbox();
// If close button is clicked...
$("#cboxClose").click(function(){
// Confirm desire to close, and only close if confirmed
if(confirm("Are you sure?")){ $.colorbox.close(); };
});
});
Note:
$(function() { ... });
is synonymous with $(document).ready(function() { ... });
精彩评论