jQuery-UI:对话框不是函数错误 [英] Jquery-UI: dialog is not a function error

查看:78
本文介绍了jQuery-UI:对话框不是函数错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我通过newDialog("This is title !", "this is my content");

function newDialog(mytitle, mycontent){
   var $dialog = $('<div id="mydialog"></div>')
        .html(mycontent)
        .dialog({
            autoOpen: false,
            modal: false,
            title: mytitle
        });
    $dialog.dialog('open');
    return false
}

这是错误

错误:$(").html(mycontent).dialog不是函数

Error: $("").html(mycontent).dialog is not a function

这是什么意思?我已经确保使用firebug插件完全加载了所有的jquery-UI和jquery js文件,以确认所有这些内容.

What does this mean ? I have made sure all the jquery-UI, and jquery js files are fully loaded using firebug plugin to confirm all of this.

我不明白为什么它会突然停止工作.

I don't understand why it would suddenly stop working.

我已经尝试过使用$(document).click(newDialog);和$('body').delegate(':not(#mydialog *,#mydialog)','click',newDialog);但错误不会消失.使用后者,因此如果不小心单击对话框,将不会生成新对话框.

I've tried it with $(document).click(newDialog); and $('body').delegate(':not(#mydialog *, #mydialog)','click', newDialog); but the error is not going away. The latter is used so new dialogs will not spawn if the dialog is accidently clicked.

$(top.document).ready(function () {   
var fruits = new Array();

   $(document).click(newDialog("happy title", "happy content to keep everyone happy"));
   //$('body').delegate(':not(#mydialog *, #mydialog)','click', newDialog);

});

推荐答案

检查dialog插件是否已正确安装.不应有任何其他原因使之不起作用.

Check that the dialog plugin is properly installed. There shouldn't be any other reason why this shouldn't work.

我可以借此机会进行一些无耻的自我推广,为您提供另一种选择.我写了一个jQuery插件,可以完成您想做的事情.如果您有兴趣,它是开源的: http://code.google.com/p/dialogwrapper/

May I take this opportunity for some shameless self-promotion to offer you an alternative. I wrote a jQuery plugin that does what you are trying to do. It's open source if you are interested: http://code.google.com/p/dialogwrapper/

这篇关于jQuery-UI:对话框不是函数错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆