在我的jQuery移動應用程序中,我有兩個頁面A和B.頁面A包含一個鏈接B. B包含一個滑塊。bxSlider沒有在頁面上顯示jQuery移動頁面
頁B:
<div data-role="page">
<div data-role="content">
<div id="list-of-people">
<div class="bxslider-header">
<fieldset data-role="controlgroup" data-type="horizontal" data-role="fieldcontain" class="header-right">
<input type="radio" name="sliderNav" id="sliderPrevious"
value="sliderPrevious"/>
<label for="sliderPrevious"><</label>
<input type="radio" name="sliderNav" id="sliderNext" value="sliderNext"/>
<label for="sliderNext">></label>
</fieldset>
</div>
<div id="sliderPeople" class="navi">
{% for person in people %}
<div class="slide">
<p>{{ person.firstname person.lastname }}</p>
</div>
{% endfor %}
</div>
</div>
</div>
<div data-role="footer" data-position="fixed" data-tap-toggle="false">
<p>my footer</p>
<script type="text/javascript">
$(function() {
var bxSliderPeople = $('#sliderPeople').bxSlider({
adaptiveHeight: true,
pager: false,
onSlideAfter: function (currentSlideNumber, totalSlideQty, currentSlideHtmlObject) {
$('#sliderPeople .active-slide').removeClass('active-slide');
$('#sliderPeople > div').eq(currentSlideHtmlObject + 1).addClass('active-slide');
},
onSliderLoad: function() {
$('#sliderPeople > div').eq(1).addClass('active-slide');
}
});
});
</script>
</div>
</div>
這纔是我的問題的描述:
==>當我加載網頁B時,滑塊顯示就好了。
==>當我通過頁面A上的鏈接(=頁面B通過ajax加載)訪問頁面B時,滑塊完全不顯示。但是,幻燈片包含在DOM中。檢查我的HTML,我看到這樣的事情:
<div class="bx-wrapper" style="max-width: 100%; margin: 0px auto;">
<div class="bx-viewport" style="width: 100%; overflow: hidden; position: relative; height: 0px;">
<div id="sliderPeople" class="navi" style="width: 1215%; position: relative; transition-duration: 0s; transform: translate3d(0px, 0px, 0px);">
...
</div>
</div>
</div>
我怎樣才能做到這一點,當我通過網頁A上的網頁鏈接訪問網頁B我的滑蓋也被顯示?
我已經嘗試過這一點,但它不工作,不幸... – Max
@Max,看到更新的答案與jsFiddle演示:http://jsfiddle.net/ezanker/bmqpx2hg/ – ezanker