提问人:sianipard 提问时间:2/15/2023 最后编辑:sianipard 更新时间:2/15/2023 访问量:22
无法从 Twitter Typeahead 结果传递值
Cannot pass value from Twitter Typeahead results
问:
我从 Twitter Typeahead 以 JSON 格式获得了这个结果:
[
{
"id": "7976",
"level1": 6,
"levelName1": "Level Three",
"level2": "5",
"levelName2": "Level Two"
}
]
使用此脚本:
$('.typeahead').bind('typeahead:select', function(ev, suggestion) {
$('#id').val(suggestion.id);
$('#level1').val(suggestion.level1);
$('#levelName1').val(suggestion.levelName1);
$('#level2').val(suggestion.level2);
$('#levelName2').val(suggestion.levelName2);
});
我想将它们传递给这个 HTML 标签:
<input type="hidden" name="id" id="id">
<label class="custom-control custom-radio">
<input id="level1" name="level" type="radio" class="custom-control-input">
<span class="custom-control-indicator"></span>
<span class="custom-control-description" id="levelName1"></span>
</label>
<label class="custom-control custom-radio">
<input id="level2" name="level" type="radio" class="custom-control-input">
<span class="custom-control-indicator"></span>
<span class="custom-control-description" id="levelName2"></span>
</label>
虽然元素“id”已成功传递,但其他元素未成功传递。
编辑1:在我尝试成功将其他结果传递给具有隐藏或文本类型属性的输入标签后,Typeahead的建议函数似乎仅将值传递给这些类型。
答: 暂无答案
评论