最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - order changed event in jquery sortable - Stack Overflow

programmeradmin1浏览0评论

Now i'm using jQuery library and i faced the folowing problem: Supppose i have the sortable list if items

    <html>
       <head>
         <script src=".js"></script>
         <script src=".4/jquery.min.js>  </script>
         <script src=".8/jquery-ui.min.js"></script>
       <script>
          $(document).ready(function(){
                jQuery(".block").sortable({
                axis: 'y'
             });
          });
      </script>

      </head>
      <body>
          <ul class="block" type="none">
               <li>1</li>
               <li>2</li>
               <li>3</li>
          </ul>
      </body>
  </html>

So ofter order changed, how can i make listener for this event, i mean ,is there any listener for order changed event or something like this.

Now i'm using jQuery library and i faced the folowing problem: Supppose i have the sortable list if items

    <html>
       <head>
         <script src="http://code.jquery./jquery-latest.js"></script>
         <script src="http://ajax.googleapis./ajax/libs/jquery/1.4/jquery.min.js>  </script>
         <script src="http://ajax.googleapis./ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
       <script>
          $(document).ready(function(){
                jQuery(".block").sortable({
                axis: 'y'
             });
          });
      </script>

      </head>
      <body>
          <ul class="block" type="none">
               <li>1</li>
               <li>2</li>
               <li>3</li>
          </ul>
      </body>
  </html>

So ofter order changed, how can i make listener for this event, i mean ,is there any listener for order changed event or something like this.

Share Improve this question asked Aug 1, 2012 at 7:18 ilya.stmnilya.stmn 1,6245 gold badges23 silver badges41 bronze badges 1
  • 1 Ya! there is check the documentation of jquery ui sortable. – SVS Commented Aug 1, 2012 at 7:20
Add a ment  | 

2 Answers 2

Reset to default 7

It's right there in the documentation. Use the change or update event:

$(document).ready(function(){
    $(".block").sortable({
        axis: 'y',
        change: function(event, ui) { 
            console.log('change', event, ui); 
        },
        update: function(event, ui) {
            console.log('update', event, ui); 
        }
    });
});

Also either use jQuery or $, don't mix them.

Yes,

$( ".selector" ).bind( "sort", function(event, ui) {
    ...
});

Directly from the documentation.

发布评论

评论列表(0)

  1. 暂无评论