jQuery的自动完成,多个分隔阵列 [英] Jquery Autocomplete, multiple separator array

查看:164
本文介绍了jQuery的自动完成,多个分隔阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$("#tags").autocomplete(["c++", "java", "php", "coldfusion", "javascript", "asp"], {
width: 320,
max: 4,
highlight: false,
multiple: true,
multipleSeparator: " ",
scroll: true,
scrollHeight: 300
});
)};

我试图使用jQuery UI自动完成与multipleSeparator。这意味着,我可以通过一个字符串数组{和或},如果有人会像键入:

I am trying to use Jquery UI autocomplete with multipleSeparator. Which means that I can pass a string array as { " AND ", " OR " } and when someone will type like:

C ++和Java和p

C++ and Java and p

在PHP会来的。

所以基本上,我试图让一个逻辑运算符基于前pression。

So basically I am trying to make a logical operator based expression.

寻找候选人:C#或C ++和ASP

Looking for Candidate: C# or C++ and ASP

我需要INTELLI感在C#以及在C ++中,但不是在或,和

I need intelli sense in C# as well as in C++ but not in or , and.

请帮我该怎么修改?

推荐答案

我设法通过得到的是:

 $.ajax({
     url: sourceUrl,
     dataType: "json",
     type: "POST",
     cache: true,
     data: {
          text: fnGetTerm(request, autoCompleteSeparator) 
     },

,其中fnGetTerm写为:

where fnGetTerm is written as:

function fnGetTerm(request, autoCompleteSeparator) {
    var startsWith = null;
    if (autoCompleteSeparator == undefined || autoCompleteSeparator == null || autoCompleteSeparator.length == 0) {
        startsWith = request.term
    }
    else {
        startsWith = fnAutoCompleteExtractLast(request.term, autoCompleteSeparator);
    }

    return $.trim(startsWith);
}

这篇关于jQuery的自动完成,多个分隔阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆