jQuery simplemodal 插件:方法 close() 导致错误
当尝试关闭简单模式对话框时,正如我在插件的网站示例中看到的那样,它是通过调用
$.modal.close() or modal.close()
但没有一个对我有用来完成的。
在 Chrome 控制台上,我得到:
Uncaught TypeError: Object #
这是完整的代码。
$('.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.fadeIn('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();
});
});
});
}
});
});
});
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.fadeIn('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();
});
});
});
}
});
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尚未在任何地方声明
modal
。您需要将modal.close();
更改为$.modal.close();
或将onClose
函数更改为:You haven't declared
modal
anywhere. You'll need to changemodal.close();
to$.modal.close();
or change youronClose
function to: