bootstrap typeahead return name and id

前端 未结 6 1493
予麋鹿
予麋鹿 2021-02-03 13:33

Hy! I\'m using twitter bootstraps typeahead:

I\'m calling a page that returns a response with json_encode the page returns a name and an ID,

I want that the type

6条回答
  •  盖世英雄少女心
    2021-02-03 14:18

    I noticed when using this code that if the match included the letters 'st', the typeahead suggestions include the style tag in the typeahead suggestions.

    For example the suggested matches would show

    style="padding: 10px; font-size: 1.5em;">standard

    instead of

    standard

    I changed the replace function to this:

    replace: function (string) {
      return String.prototype.replace.apply(this.name, arguments);
    }
    

    Obviously you lose the additional formatting, but it doesn't break on 'st' matches (I assume it would also break on 'di', or other substrings of the div tag.

提交回复
热议问题