Topic: Dual Date Picker erratic behaviour
Dave Fernandes asked 9 years ago
Michal Szymanski staff pro premium priority answered 9 years ago
var from_$input = $('#input_from').pickadate(),
from_picker = from_$input.pickadate('picker')
var to_$input = $('#input_to').pickadate(),
to_picker = to_$input.pickadate('picker')
// Check if there’s a “from” or “to” date to start with.
if ( from_picker.get('value') ) {
to_picker.set('min', from_picker.get('select'))
}
if ( to_picker.get('value') ) {
from_picker.set('max', to_picker.get('select'))
}
// When something is selected, update the “from” and “to” limits.
from_picker.on('set', function(event) {
if ( event.select ) {
to_picker.set('min', from_picker.get('select'))
}
else if ( 'clear' in event ) {
to_picker.set('min', false)
}
})
to_picker.on('set', function(event) {
if ( event.select ) {
from_picker.set('max', to_picker.get('select'))
}
else if ( 'clear' in event ) {
from_picker.set('max', false)
}
})
Dave Fernandes answered 9 years ago
Michal Szymanski staff pro premium priority answered 9 years ago
<div class="md-form">
<input placeholder="Selected date" type="text" id="input_from" class="form-control datepicker">
<label for="input_from">Try me...</label>
</div>
<div class="md-form">
<input placeholder="Selected date" type="text" id="input_to" class="form-control datepicker">
<label for="input_to">Try me...</label>
</div>
<script>
$.extend($.fn.pickadate.defaults, {
onRender: function () {
$('.picker__header').prepend('');
}
});
var from_$input = $('#input_from').pickadate(),
from_picker = from_$input.pickadate('picker')
var to_$input = $('#input_to').pickadate(),
to_picker = to_$input.pickadate('picker')
// Check if there’s a “from” or “to” date to start with.
if (from_picker.get('value')) {
to_picker.set('min', from_picker.get('select'))
}
if (to_picker.get('value')) {
from_picker.set('max', to_picker.get('select'))
}
// When something is selected, update the “from” and “to” limits.
from_picker.on('set', function (event) {
if (event.select) {
to_picker.set('min', from_picker.get('select'))
} else if ('clear' in event) {
to_picker.set('min', false)
}
})
to_picker.on('set', function (event) {
if (event.select) {
from_picker.set('max', to_picker.get('select'))
} else if ('clear' in event) {
from_picker.set('max', false)
}
})
</script>
Dave Fernandes answered 9 years ago
sirdante pro answered 8 years ago
<div class="md-form"> <input placeholder="Selected date" type="text" id="input_from" class="form-control datepicker"> <label for="input_from">Try me...</label> </div> <div class="md-form"> <input placeholder="Selected date" type="text" id="input_to" class="form-control datepicker"> <label for="input_to">Try me...</label> </div>
<script> $.extend($.fn.pickadate.defaults, { onRender: function () { $('.picker__header').prepend(''); } }); var from_$input = $('#input_from').pickadate(), from_picker = from_$input.pickadate('picker') var to_$input = $('#input_to').pickadate(), to_picker = to_$input.pickadate('picker') // Check if there’s a “from” or “to” date to start with. if (from_picker.get('value')) { to_picker.set('min', from_picker.get('select')) } if (to_picker.get('value')) { from_picker.set('max', to_picker.get('select')) } // When something is selected, update the “from” and “to” limits. from_picker.on('set', function (event) { if (event.select) { to_picker.set('min', from_picker.get('select')) } else if ('clear' in event) { to_picker.set('min', false) } }) to_picker.on('set', function (event) { if (event.select) { from_picker.set('max', to_picker.get('select')) } else if ('clear' in event) { from_picker.set('max', false) } }) </script>no longer works properly in 4.0.1 "input_to" not show the blocked days to "input_from".
Michal Szymanski staff pro premium priority answered 8 years ago
<div class="md-form">
<input placeholder="Selected date" type="text" id="input_from" class="form-control datepicker">
<label for="input_from">Try me…</label>
</div>
<div class="md-form">
<input placeholder="Selected date" type="text" id="input_to" class="form-control datepicker">
<label for="input_to">Try me…</label>
</div>
<script>
$('.datepicker').pickadate();
</script>
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
- User: Free
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No