我正在学习X-editable库,我想知道为什么官方网站上的一个示例不起作用。
JavaScript
$('#username').editable({
type: 'text',
url: '/post',
pk: 1,
title: 'Enter username',
ajaxOptions: {
dataType: 'json'
},
success: function(response, newValue) {
if(!response) {
return "Unknown error!";
}
if(response.success === false) {
return response.msg;
}
}
});
//ajax emulation
$.mockjax({
url: '/post',
responseTime: 200,
response: function(settings) {
if(settings.data.value) {
this.responseText = '{"success": true}';
} else {
this.responseText = '{"success": false, "msg": "required"}';
}
}
});
请在此处查看完整代码:
http://jsfiddle.net/xBB5x/62/
当我单击一个可编辑文本,更改它并单击“确定”按钮时,它之后什么都不会发生。我只能看到一个加载图标。有人能解释一下它怎么了吗?非常感谢。
(摘自
http://vitalets.github.io/x-editable/demo-bs3.html
部分“更多示例和技巧(jsFiddle)”)