You can use mounted
life-cycle hook for creating your datepicker and bind date-picker onSelect
event to update current model.
mounted : we need to use this because date-picker is inside Vue
and we need to initialize it when Vue is ready so we can bind events.
you can see working example below.
new Vue({
el: '#app',
data: {
date: '',
},
mounted: function() {
var self = this;
$('#datepicker').datepicker({
onSelect:function(selectedDate, datePicker) {
self.date = selectedDate;
}
});
},
methods:{
}
})
<!DOCTYPE html>
<html>
<head>
<script> console.info = function(){} </script>
<script src="https://vuejs.org/js/vue.js"></script>
<script src="https://code.jquery.com/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css" rel="stylesheet" type="text/css" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style>.half{width:50%;float:left;}</style>
</head>
<body>
<div id="app">
<input id="datepicker" v-model="date">
date: {{ date }}
</div>
</body>
</html>