Milind
Milind

Reputation: 1955

jQuery Select2 android hide keyboard

We created responsive website where we are using select2. On desktop it is working very good, but on android once keyboard appears we cannot hide it.

How can we do that.

Upvotes: 1

Views: 1697

Answers (1)

Milind
Milind

Reputation: 1955

Thank you very much for rude replies and down votes.

But I came out with workaround. First I detect device is touch or normal by below code

 var isTouchDevice = 'ontouchstart' in document.documentElement;

Then I declare normal variable and assign it with zero and in next line if the device is touch device than I will assign -1. By this I can hide and unhide search box in select2. which in turn don't show keyboard on touch devices.

var m = 0;
m = isTouchDevice === true ? -1 : 0;
 $("#selacity1").select2({
  minimumResultsForSearch: m,
  width: 210
});

It will help to somebody.

Once again thank you for down votes.

Upvotes: 3

Related Questions