簡體   English   中英

bootstrap3.0 typeahead插件不起作用

[英]bootstrap3.0 typeahead plugin not working

我正在嘗試提前完成自動完成工作,但沒有看到它正在工作。

的jsfiddle

$('#selectAgent').typeahead({
source: function(query, process) {
    objects = [];
    map = {};
    var data = [{"id":1,"label":"machin"},{"id":2,"label":"truc"}] // Or get your JSON dynamically and load it into this variable
    $.each(data, function(i, object) {
        map[object.label] = object;
        objects.push(object.label);
    });
    process(objects);
},
updater: function(item) {
    $('id').val(map[item].id);
    return item;
}
}); 

// HTML:

 <input name="selectAgent" type="text" id="selectAgent" class="validate[required] text-input form-control" data-prompt-position="topLeft:70" placeholder="type &quot;Agent name or id &quot;" title="type &quot;Agent name or id &quot;" >

正如Marwan所指出的,Typeahead已從Bootstrap中刪除。 如果您包含以下庫,則代碼實際上可以正常工作:版本2.3.2中的http://getbootstrap.com/2.3.2/assets/js/bootstrap-typeahead.js

這是工作中的小提琴

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM