Reputation: 465
I use datepicker from jQuery UI.
Here you can see my initial code
$('#fromDate').datepicker({
showOtherMonths: true,
minDate: 0,
dateFormat: 'dd MM yy',
onSelect: function(dateText, inst) {
$(this).text(dateText);
},
altField: '#startDate',
altFormat: 'dd.mm.yy'
},
$.datepicker.regional[ "ru" ]
);
After select date, datepicker destroy, but I don't need that datepicker destroy.
Upvotes: 1
Views: 2323
Reputation: 4376
The issue you were facing was because of writing to the text property of the div, to which your date picker is attached. So the idea is to create two separate divs, one for the date picker and one for the selected value.
HTML:
Date: <div id='SelectedDate'></div>
<div id='fromDate'></div>
Jquery:
$('#fromDate').datepicker({
showOtherMonths: true,
minDate: 0,
showAnim: '',
dateFormat: 'dd MM yy',
onSelect: function (dateText, inst) {
$('#SelectedDate').text(dateText);
},
altField: '#startDate',
altFormat: 'dd.mm.yy'
},
$.datepicker.regional["ru"]);
Now you can add other elements in your HTML and do a .datepicker("destroy") on lcikc when you no longer need it.
EDIT: Forgot the Fiddle Link : http://jsfiddle.net/TGy3s/1/
Upvotes: 2