Monday, April 2, 2018

SumoSelect handling events not work on android devices

Leave a Comment

I am using SumoSelect v3.0.3 on my select tag (It makes multiselect options), but i have problem with handling events on Android devices. On close select tag alert() do not appears.

Just need ANY call my function or trigger on closing sumo select. On android and desktop...

  • proper solution can be in older 3.0.2 version...

There is wokring fiddle: LINK - open and close select input after that on desktop you can see alert window with 'Drop down closed!' text but on android device no...

// .class pointing to <select> tag $('.class').SumoSelect({placeholder: 'Select choice'});  $('select').on('sumo:closed', function(sumo) {      alert("Drop down closed!"); }); 

On desktop (Firefox/Chrome) it works... Any suggestions?

I am pretty weak in javascript/jquery but in previsious version (3.0.2) i had own trigger $(document).trigger('sumoCloseSelect'); direct in sumoselect.js plugin like this (last line):

                showOpts: function () {                 var O = this;                 if (O.E.attr('disabled')) return; // if select is disabled then retrun                 O.is_opened = true;                 O.select.addClass('open');                  if(O.ftxt)O.ftxt.focus();                 else O.select.focus();                  // hide options on click outside.                 $(document).on('click.sumo', function (e) {                     if (!O.select.is(e.target)                  // if the target of the click isn't the container...                         && O.select.has(e.target).length === 0){ // ... nor a descendant of the container                         if(!O.is_opened)return;                         O.hideOpts();                         $(document).trigger('sumoCloseSelect'); 

(yes wery dirty) and after that in my main.js file:

$(document).on('sumoCloseSelect', function(e) {      alert('Drop down closed!');     ... 

But this solution not working on android too...

EDIT:

I was try add to sumoselect js file jQuery.myFunction(); (like in prev ex.) and in own js define it

    jQuery.myFunction= function(){         alert('yep!');     }; 

AND AGAIN ON DESKTOP IT WORKS BUT IT NOT WORK ON ANDROID...

EDIT2:

with init setting forceCustomRendering: true all triggers work... but i want this setting on false (default)

1 Answers

Answers 1

Why are you trying to catch the trigger with sumo plugin? What do you want to do exactly?

For example you can do it like that

$(document).on('change', 'select.class', function(sumo) {   alert("Drop down closed!"); }); 

https://jsfiddle.net/5dy8j54n/14/

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment