jquery - X-editable 官方示例(jsFiddle)不起作用

标签 jquery twitter-bootstrap jsfiddle x-editable mockjax

我正在学习 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)”)

最佳答案

您应该更新 jsFiddle 外部资源 - jquery.mockjax.js
它可以正常工作:
https://cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.6.2/jquery.mockjax.js

关于jquery - X-editable 官方示例(jsFiddle)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32691691/

相关文章:

twitter-bootstrap - 在 jsFiddle 中使用 twitter 的 Bootstrap

javascript - 删除jquery中的空双引号

javascript - 检测鼠标滚轮旋转的次数,而不是旋转的长度

html - Twitter Bootstrap3 问题

javascript - 如何从 Bootstrap 的模态形式发布数据?

javascript - 使用 jsFiddle 的全局变量

JQuery,在 jsfiddle 中工作但不在现场的 li 元素的淡入循环

php - json 中按日期列每周 header

javascript - Jquery onclick 动态变化

javascript - 完整日历未显示在 Bootstrap 模式中