Jquery data-role ="可折叠"没有被捕获

时间:2015-01-30 08:08:34

标签: jquery jquery-ui

请参阅此Fiddle

为什么Jquery数据角色="可折叠"在这种情况下被捕获?

这就是我的尝试:

HTML:

<div data-role="collapsible" data-inset="false" class="my-collaspible"><h3>'+name+' <a class="icon-pencil-1 labelEditIcon "></a></h3></div>

JS:

$(document).ready(function () {
    $('.my-collaspible').on('collapsibleexpand', function () {
        alert('Expanded');
    });
    $('.my-collaspible').on('collapsiblecollapse', function () {
        alert('Collapsed');
    });
});

这是我的代码

<head>
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>‌​
        <!--<script src="_assets/js/index.js"></script>-->
        <script src="js/jquery.mobile-1.4.5.min.js"></script>
         <script type="text/javascript" src="js/jquery.validate.js"></script>
            <script type="text/javascript" src="js/additional-methods.js"></script>
         <script type="text/javascript" src="js/jquery-ui.js"></script>
        <script src="js/custom/search.js"></script>
        <script src="js/custom/url.js"></script>

        <script type="text/javascript">

     $(document).ready(function(){

    $('.my-collaspible').bind('expand', function () {
      alert('Expanded');
      console.log('sss');
     });

     $('.my-collaspible').bind('collapse', function()
     {
       alert('Collapsed');
     });


     $('.my-collaspible').bind('collapsibleexpand', function () {
        alert("Expanded");
      });

    });

1 个答案:

答案 0 :(得分:3)

试试这个: -

$('.my-collaspible').bind('expand', function () {
  alert('Expanded');
 });

 $('.my-collaspible').bind('collapse', function()
 {
   alert('Collapsed');
 });

Demo