【问题标题】:jQuery UI - Uncaught TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'dialog'jQuery UI - Uncaught TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'dialog'
【发布时间】:2011-12-25 01:53:47
【问题描述】:

我在使用 jQuery ui 和 dialog() 函数时遇到问题:

Uncaught TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'dialog'

我搜索了很多有相同问题的人,通过正确包含 jQuery 库解决了这个问题。

这是标题:http://pastebin.com/e1cTKGK9

这是 gpf1.js 源:http://pastebin.com/0jXhU503

【问题讨论】:

  • 以后,请在问题本身中发布一些代码(不要依赖外部站点)。另外:尝试将问题缩小到特定的代码段,这样您就不必发布“代码墙”。看看How to Ask

标签: javascript jquery jquery-ui jquery-plugins jquery-events


【解决方案1】:

在 gpf1.js 文件的第 48 行

$.dialog();

这个$. 符号将对话框方法应用于整个jquery 元素。你应该对你想要的 DOM 元素使用对话框方法:

$(foo).dialog()

这是来自 jqueryui.com 的部分演示。

    $(function() {
        $( "#dialog" ).dialog();
    });
    </script>



<div class="demo">
<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
</div>

【讨论】:

  • 解决了thanx。无论如何,现在我还有另一个问题(或者可能是对话框的默认行为):选择器标识的 元素只是从标记语言中消失了,似乎完全被对话框事件删除了。这是正确的吗?
  • 在使用 dialog() 方法时,您应该将此 'modal' 配置参数设置为 true 以使用模态形式:$( "foo" ).dialog({modal: true})。更多信息请参考jqueryui.com/demos/dialog/#modal-form :)
  • @luke:尝试将&lt;input&gt; 包装在&lt;div&gt; 中,然后将dialog 应用到该位置。
  • @PPvG:同样的结果,似乎 dialog() '转换'了警报对话框中选择器标识的 div...
  • 使用隐藏的标记区域解决了 'display: none;'对于对话框。 @PPvG:我会记住你的建议,谢谢。
【解决方案2】:

这可以用下面的 sn-p 修复

// http://bugs.jquery.com/ticket/11921
if(! $.isFunction($.fn.curCSS)) {
   $.curCSS = $.css; 
   $.fn.curCSS = $.fn.css; 
   var mouseY, lastY = 0; 
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多