Cannot read property 'sumo' of undefined

1k Views Asked by At

I have a sumoselect field with active multiple choices. The input is correctly loaded and it works. I have a problem with methods. I get the undefined error Uncaught TypeError: Cannot read property 'sumo' of undefined.

For example this works $('.js-selectsumo-filter').SumoSelect(); and this returns the error $('js-selectsumo-filter')[0].sumo.unload();.

Sumoselect.js is first initialized and afterwards I call my custom js file. I am using jQuery 3.3.1.

$('.js-selectsumo-filter').SumoSelect({
             placeholder: placeholder,
             csvDispCount: 5,
             selectAll: false,
             search: true
         });
1

There are 1 best solutions below

0
ABoooo On

I've managed to find a solution how to call a method without click function as shown in the documentation.

$('.your-class-or-id').SumoSelect().sumo.selectItem('test');

selectItem can be exchanged for any other method available.