jQuery simplemodal plugin: the method close() is causing error
when trying to close the simplemodal dialog, as I see in the plugin's website examples, it is done by calling
$.modal.close() or modal.close()
But non of them worked for me.
On Chrome console I get this:
Uncaught TypeError: Object #<an HTMLDivElement> has no method 'close'
$.live.$.load.$.modal.onClose
Here is the full code.
$('.FinishUploadedFile').live('click',function(){
$('<div id="modal"></div>').load('page?n=3',function(){
$(this).modal({
overlayClose: true,
position: ['10%'],
overlayOpacity:0,
onOpen: function (dialog) {
dialog.overlay.fadeIn('normal', function () {
dialog.data.hide();
dialog.container.fad开发者_StackOverfloweIn('fast', function () {
dialog.data.slideDown('fast');
});
});
},
onClose: function (dialog) {
dialog.data.fadeOut('normal', function () {
dialog.container.slideUp('fast', function () {
dialog.overlay.fadeOut('fast', function () {
//Close the dialog.
modal.close();
});
});
});
}
});
});
});
You haven't declared modal
anywhere. You'll need to change modal.close();
to $.modal.close();
or change your onClose
function to:
onClose: function (dialog) {
var modal = this; // <- add this line
dialog.data.fadeOut('normal', function () {
dialog.container.slideUp('fast', function () {
dialog.overlay.fadeOut('fast', function () {
//Close the dialog.
modal.close();
});
});
});
}
精彩评论