You get a bonus - 1 coin for daily activity. Now you have 1 coin

how to make the selectize plugin close on touch using the touchstart event

Practice



the selectize plugin works when you click outside the select area on a desktop computer, but on a mobile device it does not work, because the browser sends a touchstart event instead of a click event

 

this problem can be solved with the following code placed after selectize is initialised

 

 

$(document).on("touchstart ", function(event) {

if (event.type == "touchstart") {

if (!$(event.target).hasClass('option')){
 
var container = $("#select-selector");
if(container.length==0) return;
property = container.selectize();
property[0].selectize.close();
}
}

 

});

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Scripting client side JavaScript, jqvery, BackBone"

Terms: Scripting client side JavaScript, jqvery, BackBone