Reputation: 69
I am learning X-editable library and I wonder why one of the examples from the official website is not working.
$('#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)" )
Upvotes: 2
Views: 1047
Reputation: 69
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
Upvotes: 2