【问题标题】:Error: this.element.uniqueId is not a function. JQuery UI. Anyone seen this before?错误:this.element.uniqueId 不是函数。 jQuery 用户界面。有人见过这个吗?
【发布时间】:2012-06-27 15:19:19
【问题描述】:
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/ui-lightness/jquery-ui.css" />
<script type="text/javascript" src="../Content/Scripts/jquery.js"></script>
<script type="text/javascript" src="../Content/Scripts/jquery.ui.core.js"></script>
<script type="text/javascript" src="../Content/Scripts/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../Content/Scripts/jquery.ui.position.js"></script>
<script type="text/javascript" src="../Content/Scripts/jquery.ui.menu.js"></script>
<script type="text/javascript" src="../Content/Scripts/jquery.ui.selectmenu.js"></script>
<script type="text/javascript" src="../Content/Scripts/jquery.ui.tabs.js"></script>

这是我的脚本和样式表导入的总和,但是当它尝试将 &lt;select&gt; 元素之一“转换”为 JQuery UI Selectmenu 时,我在 Mozilla Web Developer 的 jquery.ui.selectmenu 中收到此错误.js,并且没有应用 jquery esque 主题。

我之前看到过类似的错误,原因是脚本以错误的顺序很重要并且方法不存在,但似乎无法在这里思考可能是什么原因造成的。

任何想法都会很棒,如果需要,可以提供更多代码,但它只是一个 &lt;select&gt; 元素并应用了 $('#exampleSelect').selectmenu();

【问题讨论】:

  • 嗨@Christian,我有同样的问题,有什么解决办法吗?
  • 很有趣,我用Firefox复制了这个url中的一个例子的源代码,view.jqueryui.com/selectmenu/demos/selectmenu/default.html,我什至复制了.js,保存在我的电脑里,现在,我不不再出现此错误,但仍无法正常工作
  • 目前还没有解决方案:(。我会尝试类似的事情。
  • 如果您对此问题有任何解决方法,请告诉我。

标签: javascript jquery html jquery-ui


【解决方案1】:

只是在黑暗中随机拍摄。根据jQuery UI 1.9 upgrade guide.uniqueId() 方法仅在 jQuery UI 1.9 中引入。您的版本可能不支持上述方法,或者您可能混合了不同的版本。

【讨论】:

    【解决方案2】:

    jquery.ui.selectmenu.js 中的第 33 行更改为:

    var selectmenuId = this.element.uniqueId().attr( "id" );
    

    到:

    var selectmenuId = this.element.attr( 'id' ) || 'ui-selectmenu-' + Math.random().toString( 16 ).slice( 2, 10 );
    

    希望这会奏效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-08
      • 1970-01-01
      • 2011-07-23
      • 1970-01-01
      • 2017-01-05
      • 1970-01-01
      相关资源
      最近更新 更多