Magicsuggest - How to display selected item with a different label than the suggestion?

StackOverflow https://stackoverflow.com/questions/21788627

  •  11-10-2022
  •  | 
  •  

質問

So here's the scenario. The user can search people by either name or phone number. I like the fact that in the suggestions dropdown, it shows the person's name and phone number... and the text highlighting that goes with it. However, once they select the person, I want only the person's name to show in the selection. Not the phone number. Is there a way I can override a label/display function for selected items?

NOTE: I already have a different value/id field. So this needs to be completely independent of that.

Thanks!

役に立ちましたか?

解決

Am I the only one here using MagicSuggest? Anyway... the answer is to set a custom selectionRenderer in the declaraion.

selectionRenderer: function(obj){return obj["shortName"];}

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top