我有一組具有ID和說明的對象(採用JSON格式)。Select2與返回的值不同的選項
我需要用戶能夠在下拉菜單中看到ID或說明,但是當他們選擇ID或說明時,必須返回對象的ID。
的對象看起來是這樣的:
{
"id": 100
"name": "George Washington"
"description": "The first president of the United States."
}
在下拉菜單中,我想這兩個100
和George Washington
出現。當用戶選擇其中之一時,我想返回100
。有關如何實現此行爲的任何想法?
看看https://select2.github.io/options.html#templateSelection – ValLeNain