考虑以下代码:

在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:jqueryui-editable.js:4727上的this.tip(...)。find不是函数。

我认为这是因为与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解决了。我使用的是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

10-04 22:04
查看更多