General
Getting Started
Quick Install
Using with Cordova
Using with Vue.js
Using with Stencil.js
Using with ES Modules
Mobiscroll CLI
Working with the Source
Instance
Customizing the Look and Feel
Upgrade From Trial
Utility functions
Typings
Update version
Upgrade Guide v5
Date & Time pickers
Event Calendar
Form components
Pickers & dropdowns
Page layout
Tools
Accessibility
This version of the documentation is outdated. Check the latest version here!
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.
Sample usage
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' });