(function ($) {
$.fn.extend({
leanModal : function (options) {
var defaults = {
top : 100,
overlay : 0.5,
closeButton : null
};
var overlay = $("<div id='lean_overlay'></div>");
$("body").append(overlay);
options = $.extend(defaults, options);
return this.each(function () {
var o = options;
$(this).click(function (e) {
var modal_id = $(this).attr("href");
//$("#lean_overlay").click(function () {
// close_modal(modal_id)
//});
$(o.closeButton).click(function () {
close_modal(modal_id)
});
var modal_height = $(modal_id).outerHeight();
var modal_width = $(modal_id).outerWidth();
$("#lean_overlay").css({
"display" : "block",
opacity : 0
});
$("#lean_overlay").fadeTo(200, o.overlay);
$(modal_id).css({
"display" : "block",
"position" : "fixed",
"opacity" : 0,
"z-index" : 11000,
"left" : 50 + "%",
"margin-left" : - (modal_width / 2) + "px",
"top" : o.top + "px"
});
$(modal_id).fadeTo(200, 1);
e.preventDefault()
})
});
function close_modal(modal_id) {
$("#lean_overlay").fadeOut(200);
$(modal_id).css({
"display" : "none"
})
}
}
})
})(jQuery);
这是来自leanModal插件 - http://leanmodal.finelysliced.com.au/
我应该如何在上述插件之外调用这个 close_modal() 函数?我想从 ajax 调用的成功回调中关闭弹出对话框。ajax 调用在外部 js 函数中。