简体   繁体   English

jQuery UI对话框无法正常工作; 错误消息“ TypeError:未定义不是函数”

[英]JQuery UI dialog not working correctly; error message “TypeError: undefined is not a function”

I am trying to make a popup dialog window using JQuery UI and it opens when I click a bookmark button. 我正在尝试使用JQuery UI创建一个弹出对话框窗口,当我单击书签按钮时它将打开。

When I click first time on the button I get this error and nothing appears: 当我第一次单击按钮时,出现此错误,但未显示任何内容:

Uncaught TypeError: undefined is not a function (anonymous function)

The second time I click, the window appears. 第二次单击时,出现窗口。 If I click again, The window appears without the title and the text from the body of the window appears at the end of the picture. 如果再次单击,将出现不带标题的窗口,并且窗口正文中的文本出现在图片的末尾。

This is the code: 这是代码:

var script1 = document.createElement('script');
script1.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js';
var script2 = document.createElement('script');
script2.src = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js';

document.head.appendChild(script1);
document.head.appendChild(script2);
$("head").append("<link rel='stylesheet' href='//code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css'>");
$("body").append("<div id='dialog' title='Basic dialog'><p>This is the default dialog which is useful for displaying information. </p></div>");

$(document).ready($("#dialog").dialog());
$(document).ready($("#dialog").dialog());

是不正确的,您是将对话框返回的内容分配给就绪,而不是在就绪时调用它。

$(document).ready( function(){ $("#dialog").dialog() });

jQuery(document).ready(function ($) { $.noConflict(true); ..... });

This $.noConflict(true); $ .noConflict(true); helps me to fix the issue. 帮助我解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM