亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

twitter bootstrap typeahead ajax示例

twitter bootstrap typeahead ajax示例

侃侃無極 2019-07-31 14:41:41
twitter bootstrap typeahead ajax示例我試圖找到一個twitter bootstrap typeahead元素的工作示例,該元素將進行ajax調用以填充它的下拉列表。我有一個現有的工作jquery自動完成示例,它定義了ajax url以及如何處理回復<script type="text/javascript">//<![CDATA[ $(document).ready(function() {     var options = { minChars:3, max:20 };     $("#runnerquery").autocomplete('./index/runnerfilter/format/html',options).result(             function(event, data, formatted)                 {                     window.location = "./runner/index/id/"+data[1];                 }             );        ..我需要更改什么來將其轉換為typeahead示例?<script type="text/javascript">//<![CDATA[ $(document).ready(function() {     var options = { source:'/index/runnerfilter/format/html', items:5 };     $("#runnerquery").typeahead(options).result(             function(event, data, formatted)                 {                     window.location = "./runner/index/id/"+data[1];                 }             );        ..我將等待“ 添加遠程源支持預先輸入 ”問題得到解決。
查看完整描述

3 回答

?
慕的地8271018

TA貢獻1796條經驗 獲得超4個贊

在bootstrap 3中不再捆綁typeahead。退房:

從Bootstrap 2.1.0到2.3.2,你可以這樣做:

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

要使用這樣的JSON數據:

{
    "options": [
        "Option 1",
        "Option 2",
        "Option 3",
        "Option 4",
        "Option 5"
    ]}

請注意,JSON數據必須是正確的mime類型(application / json),因此jQuery將其識別為JSON。


查看完整回答
反對 回復 2019-07-31
?
BIG陽

TA貢獻1859條經驗 獲得超6個贊

您可以使用支持ajax調用的BS Typeahead fork。然后你就可以寫:

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


查看完整回答
反對 回復 2019-07-31
  • 3 回答
  • 0 關注
  • 684 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號