x-editable(jQuery UI构建)抛出Uncaught TypeError错误

3
考虑下面的代码:
在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>

这会抛出一个Uncaught TypeError: this.tip(...).find is not a function错误,位置在jqueryui-editable.js:4727

我猜测这是由于与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的内容。请创建一个演 - charlietfl
我正在使用来自https://vitalets.github.io/x-editable/的jQuery UI构建。所以,是的,它是相关的。 - user3262713
理解它们之间的关系有些困难,如果无法复制,那么帮助也很难。 - charlietfl
现在我已经添加了一个完整的示例,你可以将其作为HTML文件运行以复制错误。 - user3262713
这只是最少的内容,绝不是文档的“完整”副本。我已经删除了很多无关的东西。 - user3262713
显示剩余2条评论
2个回答

1

这对我也解决了问题,感谢您提供这些。 - mknopf

0

我认为这是针对jqueryui 1.11.4特定源代码的错误。看起来自2013年以来,该源代码的jquery版本没有被修改过,因此我认为它不会很快被修复。不幸的是,这是我找到的最实用的原地编辑库,所以我决心让它正常工作。

一个不错的替代方案是使用“纯”库,它根本不使用jqueryui。在我看来,它在功能上是等同的。如果你想使用“弹出”而不是“内联”模式,你还需要获取并包含 poshytip


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接