datepicker minDate
datepicker minDate
I need the minDate option to depend on a value in another datefield. I read that minDate won't accept a function, so what I have seen in non-DataTable projects is code like this:
$('[name=myradiogroup]').change(function () {
var newMininumDate = /*insert logic here*/;
$('#datepicker').datepicker('option', 'minDate', newMininumDate);
});
One way I was thinking of doing this in DataTables is to use the .clear() and .add() on open of the Editor (or select of the DataTable), like this:
var newMininumDate = /*insert logic here*/;
editor.add( {
type: 'datetime',
label: 'Start date:',
name: 'start_date',
opts: {
minDate :newMininumDate
}
} );
I just wanted to make sure this is the most efficient way to do this?
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Yep, that's a good way to go with that - and the only real solution for that use case,
Colin
thanks. here is my complete code in case anyone has the same type of need
a co-worker did this in what seems to be a cleaner way:
Thanks for posting. Here's what I tried:
Agreed - if you want to dynamically set the minDate, then using the
field().minDate()method for thedatetimeinput would be the way to do it rather than removing and adding the field each time.Allan
From: Bruce Scott
This is working for me!