我有一个带有多个标记的自动完成文本框。我想检查前五个输入的字符以匹配和截断其他字符。
请在下面找到我的 UI 屏幕:
实际上,我已经使用 shift + 箭头键自定义了 fcbk 完整插件来执行多选功能以一次选择多个项目。
我想检查前五个字符以匹配并仅截断其他字符...
我的代码如下:
var addItem = function(item, preadded){
console.log(item);
if(item.length > 1)
{
for (var i=0;i<item.length;i++)
{
var title = $(item[i]).text();
console.log('Title = ' + title);
var value = ($(item[i]).attr('rel') && $(item[i]).attr('rel') != -1 ? $(item[i]).attr('rel') : title);
var li = document.createElement('li');
var txt = document.createTextNode(title);
var aclose = document.createElement('a');
var input = addHiddenInput(value);
$(li).attr({
'class': 'bit-box'
});
$(li).prepend(txt);
$(aclose).attr({
'class': 'closebutton',
'href': '#'
});
li.appendChild(aclose);
li.appendChild(input);
holder.appendChild(li);
$(aclose).click(function(){
$(this).parent('li').fadeOut('fast', function(){
$(this).remove();
});
return false;
});
item[i].remove();
}
}
else
{
console.log(item);
var title = item.text();
console.log('title = ' + title);
var value = (item.attr('rel') && item.attr('rel') != -1 ? item.attr('rel') : title);
var li = document.createElement('li');
var txt = document.createTextNode(title);
var aclose = document.createElement('a');
var input = addHiddenInput(value);
$(li).attr({
'class': 'bit-box'
});
$(li).prepend(txt);
$(aclose).attr({
'class': 'closebutton',
'href': '#'
});
li.appendChild(aclose);
li.appendChild(input);
holder.appendChild(li);
$(aclose).click(function(){
$(this).parent('li').fadeOut('fast', function(){
$(this).remove();
});
return false;
});
}
if (!preadded) {
holder.removeChild(document.getElementById(elem[0].id));
addInput(elem);
}
if(!controlKeyPressed){
feed.hide();
}
item.remove();
}
这是我的 addItem 函数,其中 mutiselect 值被添加到带有标记的自动完成文本框中。
我的预期输出:
Manuel...
对此有什么帮助吗?