【发布时间】:2018-04-17 20:44:29
【问题描述】:
我有时在我的 html 页面中遇到问题,其中引导选择中的所有选项都显示在下拉框之外。 (附上截图) 下拉菜单
这个问题只是偶尔观察到。这些值是从 api 调用中填充的。 这是我的引导选择 css 和 js 参考: https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css, https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.js
下面是我的代码 sn-ps。
$.ajax({
url: serverName + "api/v1/get/countrylist",
type: 'GET',
headers: {
"Content-Type": "application/json",
"Authorization": "Basic " + basicKey,
"x-access-token": xAccessToken
},
success: function(response){
// console.log("visa-response: "+ response);
var countryArr = [];
response.forEach(function(item){
countryArr.push({"country": item.country, "fee": item.fee});
// console.log("my country " + item.country)
})
//console.log("countryArr-response: "+ countryArr[1].country);
countryArr.forEach(function(item){
$('.select-country .country-list').append('<option class="'+item.fee + '"' +'data-tokens="'+ item.country+'">' + item.country +'</option>')
})
$('.selectpicker').selectpicker();
},
error: function (exception) {
console.log(exception);
}
});
<div class="col-md-6 select-country">
<div class="customer-country text-center" >
<label style="margin-right:10px;"><strong>Select Your Country:</strong></label>
<select class="selectpicker country-list" data-live-search="true" data-width="auto" data-style="btn-success" data-dropup-auto="false" standard title="Select Country...">
</select>
</div>
【问题讨论】:
-
能否提供截图或更多代码?似乎没有足够的代码来解决问题
-
添加了截图..
标签: javascript jquery twitter-bootstrap bootstrap-select bootstrap-selectpicker