2017-02-25 2 views

答えて

1

...折り畳み式セット

$(".selector").on("collapsibleexpand", function(event, ui) {}); 

が、拡大されたアイテムのかを検出することがないAPIの道のエキスパンドを検出する方法がある意味折りたたまれたDIV:

$('#myc').on('collapsibleexpand', function(event, ui) { 
    $(this).find('div.ui-collapsible:not(.ui-collapsible-collapsed)')... 
}); 

またはイベントハンドラ添付:

$('a.ui-collapsible-heading-toggle').on('tap click', function(e) { 
    .... 
}) 
0123を

スニペット:

$(document).on("pagecreate", function() { 
 
    $('a.ui-collapsible-heading-toggle').on('tap click', function(e) { 
 
     if ($(this).closest('div.ui-collapsible').is('.ui-collapsible-collapsed')) { 
 
      console.log('tap click: ' + this.childNodes[0].textContent); 
 
     } 
 
    }) 
 

 
    $('#myc').on('collapsibleexpand', function(event, ui) { 
 
     var ele = $(this).find('div.ui-collapsible:not(.ui-collapsible-collapsed)'); 
 
     console.log('collapsibleexpand: ' + ele.find('a.ui-collapsible-heading-toggle').get(0).childNodes[0].textContent); 
 
    }); 
 

 
});
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" /> 
 
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> 
 
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> 
 

 

 
<div data-role="content" id="myc"> 
 
    <div data-role="collapsible"> 
 
     <h3>I'm a header1</h3> 
 
     <p>I'm the collapsible content. By default I'm closed, but you can click the header to open me.</p> 
 
    </div> 
 
    <div data-role="collapsible"> 
 
     <h3>I'm a header2</h3> 
 
     <p>I'm the collapsible content. By default I'm closed, but you can click the header to open me.</p> 
 
    </div> 
 
</div>

+0

こんにちは!実際には、この展開されたアイテムのコンテンツにアクセスしたいと思います。あなたの解決策を抑止してください。 –

+2

jQMでリスナーを接続するときは、 '.ready'ではなく' pagecreate'でラップする必要があります。 – Omar

+0

@Omar折りたたみアイテムのdivのコンテンツにアクセスするにはどうすればいいですか? –

関連する問題