-1

我注意到引导令牌字段在 android(智能手机)中效果不佳。我定义的分隔符在android中不起作用。它仅适用于 PC。有解决方案吗?

4

1 回答 1

0
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(); 
     }

     }
});
于 2021-04-15T15:23:22.787 回答