簡體   English   中英

ajax,php和twitter的引導程序提前輸入

[英]ajax, php and twitter's bootstrap typeahead

好吧,所以我試圖填充Twitter引導程序的預輸入,然后我遵循以下答案: Twitter bootstrap Typeahead填充hrefs

但我不斷得到:

未捕獲到的TypeError:無法調用未定義的edit-group?id = 14:239的方法“ toLowerCase” $ .typeahead.matcher edit-group?id = 14:239

這是它的代碼:

matcher: function (obj) {
    var item = JSON.parse(obj);
    return ~item.title.toLowerCase().indexOf(this.query.toLowerCase())
},

我查看了“網絡”標簽,以查看是否獲得正確的數據,並得到以下信息:

0: {title:The1Prodigy1, href:1}
href: 1
title: "The1Prodigy1"
1: {title:test_suspend_user, href:4}
href: 4
title: "test_suspend_user"
    2: {title:test_ban_user, href:5}
3: {title:test_delete_user, href:6}
4: {title:user_test_edit, href:7}

最后一個問題,我需要href嗎? 因為,我要做的就是幫助用戶鍵入正確的用戶名。 我不希望將其鏈接到其他頁面或其他任何內容。 這是一種形式...

編輯:我添加了有關item.title的警報,它發送回未定義的...為什么?

謝謝,阿拉

如果您的Typeahead source中的項目是對象,那么您將不得不跳過一些障礙。 否則,當Bootstrap Typeahead嘗試在內部調用toLowerCase()來比較項目,對項目進行排序等時,您將收到該錯誤。

我不久前發布了有關如何執行此操作的博客文章: http : //victorblog.com/2013/06/21/how-to-use-rich-objects-and-typed-objects-with-bootstrap-typeahead/

我確定您只是沒有重寫Typeahead的updater功能。

暫無
暫無

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

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