【问题标题】:jQuery TagIt: autocomplete is not workingjQuery TagIt:自动完成功能不起作用
【发布时间】:2012-08-29 13:41:44
【问题描述】:

我正在使用 jquery tagit api,并且我已经编写了类似的代码

  $(document).ready(function() {
  $("#mytags").tagit({
    tagSource: function(search, showChoices) {
      $.ajax({
        url: "http://localhost/UI/user/taggin.php",
        data: {search: search.term},
        success: function(choices) {
          showChoices(choices);
        }
      });
    }
  });
  });

这是我的 html

            <tr>                        
                    <td>Tags</td>
                        <td><input id="mytags"  class= "ulc" name = "mytags"></ul>
                    </td>

                </tr>   

我的http://localhost/UI/user/taggin.php 正在返回类似

的数据
["tag1","tag2","surgeon"]

json格式

请告诉我我做错了什么,所以我的自动完成在这里不起作用

【问题讨论】:

  • jquery 选择比 tagit 好

标签: php javascript jquery tags


【解决方案1】:

试试这个

tagSource: function(search, showChoices) {
    var that = this;
    $.ajax({
        url: "/tags/autocomplete.json",
        data: {
            q: search.term
        },
        success: function(choices) {
            showChoices(that._subtractArray(choices, that.assignedTags()));
        }
    });
}​

看看这个github issue

【讨论】:

    【解决方案2】:

    Jquery UI's autocomplete 是另一种选择。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-25
      • 2014-01-16
      • 2016-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-12
      相关资源
      最近更新 更多