简体   繁体   中英

X-editable official example (jsFiddle) doesn't work

I am learning X-editable library and I wonder why one of the examples from the official website is not working.

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"}';
        }
    }
}); 

See full code here: http://jsfiddle.net/xBB5x/62/

When I click on an editable text, change it and click 'ok' button, nothing happens after it. The only thing I can see is a loading icon. Can anybody explain what's wrong with it? Thank you!

(taken from http://vitalets.github.io/x-editable/demo-bs3.html section "More examples and tricks (jsFiddle)" )

You should update jsFiddle External Resource - jquery.mockjax.js
It works fine with this:
https://cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.6.2/jquery.mockjax.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM