我有一個靜態幻燈片與Bootstrap3旋轉木馬,工作正常,我的目標是使其動態。當圖像不顯示時,我無法弄清楚,而字幕卻可以。全屏圖像背景Bootsrap3旋轉木馬拒絕diplay
這個網站是直接婁body標籤,任何其他內容之前,按規定:
<div class="carousel slide carousel-fade" data- ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
</div>
</div>
而且javascript功能:
function loadBanners() {
var json;
$.ajax({
type: "GET",
url: "BannerServ",
dataType: "json",
success: function(data) {
json = JSON.stringify(data);
$.each(
$.parseJSON(json),
function(index, arrayObj) {
var imageName = arrayObj.image;
var caption = arrayObj.title;
var $cssStyle = "{ background: url(" + imageName + ") no-repeat center center fixed;\
-webkit-background-size: cover;\
-moz-background-size: cover;\
-o-background-size: cover;\
background-size: cover; }";
$('<div class="item"><div class="carousel-caption">' + caption + '</div></div>').appendTo('.carousel-inner');
$('.item:nth-child(' + index + 1 + ')').css($cssStyle);
});
$('.item').first().addClass('active');
$('.carousel').carousel({
interval: 1000 * 10
});
}
});
}
請我需要幫助來渲染圖像。
這可能涉及到引導JS之前,你的圖像已經準備好初始化。嘗試在加載所有圖像時加載或初始化Bootstrap JS AFTER成功完成ajax調用。 –
我做了這個,但它仍然沒有顯示:完成:function(){ $('。carousel')。carousel({0}interval:1000 * 10 }); } – user3673744