API
Datepicker
Parameters
element
HTMLElement DOM element for component instantiation and scopeoptions
Object (optional, default{}
)options.datepickerFormat
String Format for datesoptions.format
(optional, default'DD-MM-YYYY'
)options.theme
(optional, default'ecl-datepicker-theme'
)options.yearRange
(optional, default40
)options.reposition
(optional, defaultfalse
)options.showDaysInNextAndPreviousMonths
(optional, defaulttrue
)options.enableSelectionDaysInNextAndPreviousMonths
(optional, defaulttrue
)
init
Initialise component.
autoInit
Parameters
root
HTMLElement DOM element for component instantiation and scope$1
Object (optional, default{}
)$1.DATEPICKER
(optional, default{}
)
Returns Datepicker An instance of Datepicker.
Setup
There are 2 ways to initialise the component.
Automatic
Add data-ecl-auto-init="Datepicker"
attribute to component's input markup:
<input class="ecl-datepicker__field ecl-text-input ecl-text-input--s" data-ecl-auto-init="Datepicker" data-ecl-datepicker-toggle >
...
</div>
Use the ECL
library's autoInit()
(ECL.autoInit()
) when your page is ready or other custom event you want to hook onto.
Manual
Get target element, create an instance and invoke init()
.
Given you have 1 element with an attribute data-ecl-datepicker-toggle
on the page:
var elt = document.querySelector('[data-ecl-datepicker-toggle]');
var datepicker = new ECL.Datepicker(elt);
datepicker.init();