ajaxアコーディオンでページの読み込み時にYiiフレームワークコンポーネントCLISTVIEWを使用すると、動作が停止します
私はフォローしようとしましたが、うまくいきませんでした
$(".items").on('load',function(){
$(this).accordion();
});
フォームの読み込み時にイベントの種類を変更してクリックすると、機能し始めます。ここで呼び出すのに適切なイベントの種類は何でしょうか。
アコーディオン プラグインは、次の種類のコンテンツを想定しています。
<h3>Section 1</h3>
<div>
<p>Content section 1</p>
</div>
<h3>Section 2</h3>
<div>
<p>Content section 2</p>
</div>
しかし、私があなたの状況を理解していれば、次のようなコードがあります:
<body>
<div class="items">
<h3>Section 1</h3>
<div>
<p>Content section 1</p>
</div>
</div>
<div class="items">
<h3>Section 2</h3>
<div>
<p>Content section 2</p>
</div>
</div>
</body>
このスクリプトでは、最初に .wrapAll .items 要素を作成してから、アコーディオン プラグインが必要とするように要素を書き換えます。
<script>
$(function() {
$('.items').wrapAll($('<div>').attr('id','accordion'));
$.each($('.items'),function(){
$(this).remove();
$('#accordion').append($(this).html());
});
$('#accordion').accordion();
});
</script>
HTML は次のようになります。
<div id="accordion">
<h3>Section 1</h3>
<div>
<p>Content section 1</p>
</div>
<h3>Section 2</h3>
<div>
<p>Content section 2</p>
</div>
</div>
そして、アコーディオンはうまく機能します。