0

Twitterのブートストラップの先行入力プラグインを適用する方法を一日中探していましたが、何も見つかりませんでした。さて、codeigniter で Twitter ブートストラップ typeahead を使用するにはどうすればよいですか?

4

1 に答える 1

2

BS Typeahead forkを使用できます。これは ajax 呼び出しをサポートしています。

# This example does an AJAX lookup and is in CoffeeScript
  $('.typeahead').typeahead(
    # source can be a function
    source: (typeahead, query) ->
      # this function receives the typeahead object and the query string
      $.ajax(
        url: "/lookup/?q="+query
        # i'm binding the function here using CoffeeScript syntactic sugar,
        # you can use for example Underscore's bind function instead.
        success: (data) =>
          # data must be a list of either strings or objects
          # data = [{'name': 'Joe', }, {'name': 'Henry'}, ...]
          typeahead.process(data)
      )
    # if we return objects to typeahead.process we must specify the property
    # that typeahead uses to look up the display value
    property: "name"
  )

例えば ​​:-

$('.typeahead').typeahead({
    source: function (query, process) {
        return $.get('/typeahead', { query: query }, function (data) {
            return process(data.options);
        });
    }
});

または、使用できます:- Ajax-Typeaheadこのプラグインはうまく機能します

于 2012-10-03T13:47:07.177 に答える