2

In my project I want to use either

As far as I know, none of the two libraries support mobile devices so I need to handle that. As far as typeahead goes they have an issue that they said they are not going to fix https://github.com/twitter/typeahead.js/issues/324

Although I expect a very small number of users using a mobile device (my web app is some kinda dashboard and not really suitable on small screens) I would like to be able to detect that case and at least being able to give them a standard HTML input text.

Any suggestions ?

Particularly for complete.ly

rowly
  • 647
  • 2
  • 8
  • 10

1 Answers1

2

First you should find a way to determine if you are running on the mobile or not.

see: Detecting a mobile browser

For complete.ly you could do something like this:

if (typeof window.orientation !== 'undefined') { 
    // mobile.
    var input = document.createElement('input');
    input.type = 'text'
    ...
    document.getElementById('container').appendChild(input);
    ... 
} else {
    var completely = document.getElementById('container'); 
    ...
    ...
}

arguably this could be handled by complete.ly itself.

Community
  • 1
  • 1
Zo72
  • 14,593
  • 17
  • 71
  • 103