x-editable combodate
by mccarthysean
HTML
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap-combined.min.css">
<link rel="stylesheet" href="http://vitalets.github.com/x-editable/assets/x-editable/bootstrap-editable/css/bootstrap-editable.css">
<script src="http://vitalets.github.com/x-editable/assets/x-editable/bootstrap-editable/js/bootstrap-editable.js"></script>
<script src="http://vitalets.github.com/x-editable/assets/mockjax/jquery.mockjax.js"></script>
<head>
<!-- Bootstrap 3.0 bundle -->
<!-- <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> -->
<!-- Bootstrap 4.6 bundle -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
<!-- Moment.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js" integrity="sha512-qTXRIMyZIFb8iQcfjXWCO8+M5Tbc38Qi5WzdPOYZHIlZpzBHG3L3by84BBBOiRGiEb7KKtAOAs5qYdUiZiQNNQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<!-- JQuery "Mockjax" (requires JQuery) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.6.2/jquery.mockjax.js"></script>
<!-- Bootstrap 3 X-editable -->
<!-- <link...
JavaScript
$(document).ready(function() {
// 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"}';
}
}
});
// This one works
$('#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 "It works!";
return response.msg;
}
}
});
// This one works too
$("#date1").editable({
type: 'combodate',
url: '/post',
pk: 490,
title: 'Enter date',
ajaxOptions: {
dataType: 'json'
},
success: function(response, newValue) {
if(!response) {
return "Unknown error!";
}
if(response.success === false) {
return response.msg;
}
}
});
//
$("#date2").editable({
type: 'combodate',
url: '/post',
pk: 490,
title: 'Enter date',
ajaxOptions: {
dataType: 'json'
},
success: function(response, newValue) {
if(!response) {
return "Unknown error!";
}
if(response.success === false) {
return response.msg;
}
}
});
//
$("#date3").editable({
type: 'combodate',
url: '/post',
pk: 490,
...