考虑下面的代码:
在jQuery的document.ready函数中:
在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>