【问题标题】:x-editable (jQuery UI build) throws Uncaught TypeErrorx-editable (jQuery UI build) 抛出 Uncaught TypeError
【发布时间】:2015-10-14 03:11:23
【问题描述】:

考虑以下代码:

jQuery document.ready:

$.fn.editable.defaults.mode = 'popup';
$("#username").editable({
        send: 'never',
       success: function(response, newValue) {
        userModel.set('username', newValue); //update backbone model
       }
});

HTML:

<div class="editable">
     <a href="#" id="username" data-type="text" data-pk="1" data-url="/post" data-title="Enter username">superuser</a>
</div>

这会在 jqueryui-editable.js:4727 处抛出 Uncaught TypeError: this.tip(...).find is not a function。

我认为这是因为与 jQuery UI 版本不兼容。但是我该如何解决呢?

更新:添加完整示例:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  <link href="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/>
  <script src="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/jqueryui-editable/js/jqueryui-editable.min.js"></script>
  <script>
    $(function() {
        $.fn.editable.defaults.mode = 'popup';
        $("#username").editable({
            send: 'never',
           success: function(response, newValue) {
            userModel.set('username', newValue); //update backbone model
        }
        });
      });
  </script>
</head>
<body>
    <div class="editable">
        <a href="#" id="username" data-type="text" data-pk="1" data-url="/post" data-title="Enter username">superuser</a>
    </div>
</body>
</html>

【问题讨论】:

  • 没有显示与 jQuery UI 相关的问题。创建一个复制问题的演示
  • 我正在使用来自 https://vitalets.github.io/x-editable/ 的 jQuery UI 构建。所以是的,它是相关的。
  • 了解它以某种方式相关但无法复制这很难提供帮助
  • 现在我添加了一个完整的示例,您可以将其作为 HTML 文件运行以复制错误。
  • 一个 dmoe 应该只包含复制问题所需的最少数量。这是文档的完整副本,而不是 MCVE 。最好使用像 jsfiddle.net 或 plnkr.co 这样的沙箱,人们可以在其中使用代码进行分叉和更改

标签: javascript jquery jquery-ui typeerror x-editable


【解决方案1】:

我有同样的错误,但通过使用旧版本的 jquery-ui 解决了它。我在 v 1.12.0 上,但注意到可编辑的演示使用了 1.10.1。使用 1.10.1 版本的 jquery-ui 让我可以使用 editable。

我正在使用

https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/smoothness/jquery-ui.css

和

https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js

【讨论】:

  • 这也解决了我的问题,感谢提供这些
【解决方案2】:

我认为这是特定于 jqueryui 1.11.4 的源代码中的一个错误。 自 2013 年以来,源代码的 jquery 版本似乎没有被触及,所以我认为它不会很快得到修复。不幸的是,这是我发现的最实用的就地编辑库,所以我决心让它发挥作用。

一个不错的选择是使用完全不使用 jqueryui 的库的“普通”版本。在我看来,它在功能上是等效的。如果你想要“弹出”而不是“内联”模式,你还需要抓取并包含poshytip

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-04
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-09
    相关资源
    最近更新 更多