Mobiscroll Instance
When a mobiscroll component is initialized, an instance of the component is created. Through the instance you have access to all methods and properties of the component.
There are multiple ways to access the instance of an individual component.
1. Inside events
The mobiscroll instance is passed as parameter for every event of the component.
mobiscroll.datepicker('#mydate', {
onClose: function (event, inst) {
const selectedDate = inst.getVal(); // Call the getVal method
}
});
2. Initialization
The instance is returned by the component's initialization:
const inst = mobiscroll.datepicker('#mydate');
inst.open(); // Call the open method
Setting options dynamically
To change one or more options on the component after initialization, use the setOptions method. This will update the component without losing it's internal state.
var inst = mobiscroll.scroller({
theme: 'ios'
});
// Changes the theme to Material
inst.setOptions({ theme: 'material' });