Bootstrap tokenfield on android

46 Views Asked by At

I have noticed that bootstrap tokenfield works badly in android (smartphone). The delimiter that I have defined does not work in android. It only works on a PC. Is there a solution for this?

1

There are 1 best solutions below

0
On
var getKeyCode = function (str) {
    return str.charCodeAt(str.length-1);
}

var noCommentVariableTwoWeeks = '';
$("#speakersAjaxId-tokenfield").on("keyup",function(e){

    //for android chrome keycode fix
    if (navigator.userAgent.match(/Android/i)) {

        var inputValue = this.value;

        var charKeyCode = e.keyCode || e.which;

        if (charKeyCode == 0 || charKeyCode == 229) {
            charKeyCode = getKeyCode(inputValue);
            noCommentVariableTwoWeeks = charKeyCode;
        }else{
            noCommentVariableTwoWeeks = charKeyCode;
        }

//przecinek = 44
    if (noCommentVariableTwoWeeks == 44) {
        //e.preventDefault();
        $('#speakersAjaxId').tokenfield('createToken', inputValue.slice(0,-1));  
        $('#speakersAjaxId-tokenfield').val('');
        $("#speakersAjaxId-tokenfield").blur(); 
        $("#speakersAjaxId-tokenfield").focus(); 
     }

     }
});