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' });