How to save mobiscroll instances created with enhance to delete them later?

We tried to use a code like this:

var instancesMobiscroll = [];

var x = document.getElementById('y');
mobiscroll.enhance(x);
instancesMobiscroll.push(x.mobiscroll('getInst'));

...

for (var i = 0; i < instancesMobiscroll.length; i++) {
	instancesMobiscroll[i].destroy();
}

and we have this error:

Uncaught TypeError: x.mobiscroll is not a function

Thank you.

Hi Bogan,

The mobiscroll instance can be retrieved from the input elemets, so you’ll have to query those in the enhanced container, also the mobiscroll.getInst mehtod should be used.

Here is an example:

var x = document.getElementById('y');
mobiscroll.enhance(x);
        
const input = x.querySelector('input');
const inst = mobiscroll.getInst(input);

Let me know if this helps!

Hi szili1

In the meantime, I solved it using the same solution. So I confirm that it is good.

Thank you.