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

4

1 回答 1

2

首先,您应该找到一种方法来确定您是否在移动设备上运行。

请参阅:检测移动浏览器

对于 complete.ly,您可以执行以下操作:

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'); 
    ...
    ...
}

可以说这可以由 complete.ly 自己处理。

于 2013-09-23T20:09:19.570 回答