Skip to content

Instantly share code, notes, and snippets.

@anotherJay
Created October 22, 2012 21:33
Show Gist options
  • Select an option

  • Save anotherJay/3934557 to your computer and use it in GitHub Desktop.

Select an option

Save anotherJay/3934557 to your computer and use it in GitHub Desktop.
Jeditable + bootstrap datepicker custom type example
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>jeditable + bootstrap datepicker custom type demo</title>
<link rel="stylesheet" type="text/css" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://raw.github.com/eternicode/bootstrap-datepicker/master/css/datepicker.css">
</head>
<body>
<div class="container">
<div class="hero-unit">
<h1>Jeditable Bootstrap Datepicker Demo</h1>
<p>
<strong>Date:</strong> <span class="editable">date</span>
</p>
</div>
</div>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.2.js'></script>
<script type='text/javascript' src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script>
<script type='text/javascript' src="http://www.appelsiini.net/download/jquery.jeditable.js"></script>
<script type='text/javascript' src="https://raw.github.com/eternicode/bootstrap-datepicker/master/js/bootstrap-datepicker.js"></script>
<script type='text/javascript'>
$(window).load(function(){
$.editable.addInputType('datepicker', {
element: function(settings, original) {
var input = $('<input/>');
$(this).append(input);
return (input);
},
plugin: function(settings, original) {
settings.onblur = 'ignore';
$(this).find('input').datepicker({
'autoclose': true,
format: 'dd-mm-yyyy'
});
}
});
$('.editable').editable(
function(value, settings) {
return (value);
}, {
type: 'datepicker',
indicator: 'Saving...',
tooltip: 'Double-click to edit...',
placeholder: '<span class="muted">Double-click to edit...</span>',
cancel: '<button class="btn btn-mini" type="cancel" >Cancel</button>',
submit: '<button class="btn btn-mini btn-primary" type="submit" >Save</button>',
style: 'display: inline;',
width: 'none',
event: 'dblclick',
}
);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment