Initializing the Picker
The range picker can be used on a Mobiscroll input or any other input part of an existing form.
There are three ways to use the range picker:
- Initialize it on a single input, either Mobiscroll or non-Mobisroll input.
- Use it with two separate inputs of any type, one for
startand another forend - Embed the picker without an input. This can be the page itself or a more complex popup
Demo
Initialize it on any input, like a new mobiscroll field or an existing field from your form.
html<label>
Range
<input id="range" mbsc-input placeholder="Please select..." />
</label>
js$('#range').mobiscroll().datepicker({
select: 'range'
});
When using two separate inputs for start and end, you will want to initialize the component on the first input and make sure to pass the references of the two inputs through the startInput and endInput options.
html<label>
Start
<input id="start" mbsc-input placeholder="Please select..." />
</label>
<label>
End
<input id="end" mbsc-input placeholder="Please select..." />
</label>
js$('#start').mobiscroll().datepicker({
select: 'range',
startInput: '#start',
endInput: '#end'
});
It can be embedded into the page or a popup as an inline picker by setting the display option to inline. You can choose to initialize the picker on an input type="hidden" or just simply a div.
html<input id="range" type="hidden" />
js$('#range').mobiscroll().datepicker({
select: 'range',
display: 'inline'
});
mobiscroll.setOptions({
locale: ,
theme: ' ',
themeVariant: ' '
});
$(function () {
$('#demo-one-input')
.mobiscroll()
.datepicker({
controls: ['calendar'],
select: 'range',
display: 'anchored',
});
$('#demo-start-end')
.mobiscroll()
.datepicker({
controls: ['calendar'],
select: 'range',
display: 'anchored',
startInput: '#demo-init-start',
endInput: '#demo-init-end',
});
$('#demo-init-inline')
.mobiscroll()
.datepicker({
controls: ['calendar'],
select: 'range',
display: 'inline',
});
});
<label>
Range
<input id="demo-one-input" mbsc-input data-input-style="outline" data-label-style="stacked" placeholder="Please select..." />
</label>
<div id="demo-start-end"></div>
<div class="mbsc-grid mbsc-no-padding">
<div class="mbsc-row">
<div class="mbsc-col-6">
<label>
Start
<input id="demo-init-start" mbsc-input data-input-style="outline" data-label-style="stacked" placeholder="Please select..." />
</label>
</div>
<div class="mbsc-col-6">
<label>
End
<input id="demo-init-end" mbsc-input data-input-style="outline" data-label-style="stacked" placeholder="Please select..." />
</label>
</div>
</div>
</div>
<div id="demo-init-inline"></div>