0

私は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形式で

私のオートコンプリートがここで機能しないので、私が間違っていることを教えてください

4

2 に答える 2

0

JqueryUIのオートコンプリートは別のオプションです。

于 2012-08-30T19:31:24.820 に答える
0

Try this

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

Take a look on this github issue

于 2012-08-29T16:08:41.210 に答える