有没有办法将twitter bootstrap的typeahead函数转换为$(“body”).on()函数?如果页面加载中存在该元素,则以下代码可以正常工作.
$("#job_title").typeahead({
source: searchFunction,onselect: function(obj) {
}
});
最佳答案
此解决方案不需要额外的JavaScript.从https://stackoverflow.com/a/15094730起
$("#element-that-will-contain-typeaheads").on("DOMNodeInserted",function () {
$(this).find(".typeahead").typeahead();
});