0
ボタンをクリックした後に画面にレンダリングされるコンテンツが多い場合は、単にoverflow-y: scroll
を作成します。上記apiFunction.increaseSize
関数呼び出しで、私は上記のHTMLに示されている#hit-template
に表示される項目の数を増やす 高さが変更されたときにスクロール可能なオーバーフローを作成しますか?
$(document).on('click', '.show-more', function(e) {
e.preventDefault();
apiFunction.increaseSize({sizeToIncreaseTo: 2}, function(error, results, state){
renderHits(results);
var rightCol = $("#right-column");
rightCol.css('overflow-y', 'scroll');
})
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="right-column">
<div id="hits"></div>
<div id="pagination"></div>
</div>
<script type="text/template" id="hit-template">
{{#hits}}
<div class="hit">
<div class="hit-image">
<img src="{{ image_url }}" alt="{{ _highlightResult.name.value }}">
</div>
<div class="hit-content">
<h3 class="hit-name">{{{ name }}}</h3>
<span class="stars-count">{{{stars_count}}}</span>
<span class="stars-empty">
<span class="stars">{{{stars_count}}}</span>
</span>
<span class="reviews-count">({{{reviews_count}}} Reviews)</span>
<p class="hit-description">{{{ food_type }}} | {{{ neighborhood }}} | {{ price_range }} </p>
</div>
</div>
{{/hits}}
</script>
<!-- Pagination template -->
<script type="text/template" id="pagination-template">
<button class="show-more">Show More</button>
</script>
renderHits
関数は、APIによって返されるコンテンツに基づいて2つの
.hit
個のdivを追加します。コンテンツが表示されているとき、私は単に
.right-column
を
overflow-y: scrollable
(元々はスクロールできないとき)にしたいと思っています。私は
right-column
のサイズを拡張したくないのですが、むしろ全体をスクロール可能にするでしょう。これは可能ですか?
完璧!ありがとうございました! – user1871869