jquery-ui – jQueryUI – 未捕获异常:无法调用方法

前端之家收集整理的这篇文章主要介绍了jquery-ui – jQueryUI – 未捕获异常:无法调用方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我非常新的jQuery和试图在我的程序中运行一个非常简单的jQueryUI对话框。在firebug控制台中我得到的错误
  1. uncaught exception: cannot call methods on dialog prior to initialization; attempted to call method 'open'

这里是我的代码

  1. $(function() {
  2. $( "#dialog" ).dialog({
  3. autoOpen: false,show: "blind",hide: "explode"
  4. });
  5.  
  6. $( "#opener" ).live('click',function() {
  7. $( "#dialog" ).dialog( "open" );
  8. return false;
  9. });
  10. });

我做了一些googling的错误,没有太多的反应,除了jquery.ui.js生成错误

  1. if ( isMethodCall ) {
  2. this.each(function() {
  3. var instance = $.data( this,name );
  4. if ( !instance ) {
  5. throw "cannot call methods on " + name + " prior to initialization; " +
  6. "attempted to call method '" + options + "'";
  7. }
  8. ...

有任何想法吗?我欣赏任何帮助,这个错误消息是什么,以及如何解决它。

更新:我试图注释显示/隐藏选项,这对我的问题没有任何影响。下面是HTML:

  1. <div class="demo">
  2.  
  3. <div id="dialog" title="Basic dialog">
  4. <p>This is an animated dialog which is useful for displaying information. The dialog window can be moved,resized and closed with the 'x' icon.</p>
  5. </div>
  6.  
  7. <button id="opener">Open Dialog</button>
  8.  
  9. </div><!-- End demo -->

此HTML包含在PHP文件中,该文件在另一个PHP文件中包含。

解决方法

OK,它与我的对话框DIV放在一个PHP文件,还没有加载到我的JS加载时的事实。所以我把对话框的DIV移动到更高的页面,这个按钮在我的应用程序的任何页面上工作。我希望这可以帮助别人。

猜你在找的jQuery相关文章