General
Getting Started
Quick Install
Using with Cordova
Using with jQuery Mobile
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
$('#mydate').mobiscroll().datepicker({
onClose: function (event, inst) {
const selectedDate = inst.getVal(); // Call the getVal method
}
});
2. Using the 'getInst' method.
The instance is returned by the component's 'getInst' method:
$('#mydate').mobiscroll().datepicker();
const inst = $('#mydate').mobiscroll('getInst');
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.
$('#elm').mobiscroll().scroller({
theme: 'ios'
});
// Changes the theme to Material
$('#elm').mobiscroll('setOptions', { theme: 'material' });