开发者

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() { ... });

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜