Official example "Shoping Cart" is not worked with .draggable option "connectToSortable"!

Official example "Shoping Cart" is not worked with .draggable option "connectToSortable"!

I found that Official example "Shoping Cart" not firing using connectToSortable option.


My code present here:


  1. <html>
  2. <head>
  3.     <title></title>
  4.     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
  5.     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.js"></script>
  6. </head>
  7. <body>
  8.     <style type="text/css">
  9.         h1
  10.         {
  11.             padding: .2em;
  12.             margin: 0;
  13.         }
  14.         #products
  15.         {
  16.             float: left;
  17.             width: 500px;
  18.             margin-right: 2em;
  19.         }
  20.         #cart
  21.         {
  22.             width: 200px;
  23.             float: left;
  24.         }
  25.         /* style the list to maximize the droppable hitarea */
  26.         #cart ol
  27.         {
  28.             margin: 0;
  29.             padding: 1em 0 1em 3em;
  30.         }
  31.     </style>
  32.     <script>
  33.         $(function ()
  34.         {
  35.             $("#catalog").accordion();
  36.             $("#catalog li").draggable({
  37.                 appendTo: "body",
  38.                 helper: "clone",
  39.                  connectToSortable: "#widget-content li"
  40.             });
  41.             $("#cart ol").droppable({
  42.                 activeClass: "ui-state-default",
  43.                 hoverClass: "ui-state-hover",
  44.                 accept: ":not(.ui-sortable-helper)",
  45.                 drop: function (event, ui)
  46.                 {
  47.                     $(this).find(".placeholder").remove();
  48.                     $("<li></li>").text(ui.draggable.text()).appendTo(this);
  49.                 }
  50.             }).sortable({
  51.                 items: "li:not(.placeholder)",
  52.                 sort: function ()
  53.                 {
  54.                     // gets added unintentionally by droppable interacting with sortable
  55.                     // using connectWithSortable fixes this, but doesn't allow you to customize active/hoverClass options
  56.                     $(this).removeClass("ui-state-default");
  57.                 }
  58.             });
  59.         });
  60.     </script>
  61.     <div class="demo">
  62.         <div id="products">
  63.             <h1 class="ui-widget-header">
  64.                 Products</h1>
  65.             <div id="catalog">
  66.                 <h3>
  67.                     <a href="#">T-Shirts</a></h3>
  68.                 <div>
  69.                     <ul>
  70.                         <li>Lolcat Shirt</li>
  71.                         <li>Cheezeburger Shirt</li>
  72.                         <li>Buckit Shirt</li>
  73.                     </ul>
  74.                 </div>
  75.                 <h3>
  76.                     <a href="#">Bags</a></h3>
  77.                 <div>
  78.                     <ul>
  79.                         <li>Zebra Striped</li>
  80.                         <li>Black Leather</li>
  81.                         <li>Alligator Leather</li>
  82.                     </ul>
  83.                 </div>
  84.                 <h3>
  85.                     <a href="#">Gadgets</a></h3>
  86.                 <div>
  87.                     <ul>
  88.                         <li>iPhone</li>
  89.                         <li>iPod</li>
  90.                         <li>iPad</li>
  91.                     </ul>
  92.                 </div>
  93.             </div>
  94.         </div>
  95.         <div id="cart">
  96.             <h1 class="ui-widget-header">
  97.                 Shopping Cart</h1>
  98.             <div class="ui-widget-content">
  99.                 <ol id="widget-content" >
  100.                     <li class="placeholder">Add your items here</li>
  101.                 </ol>
  102.             </div>
  103.         </div>
  104.     </div>
  105.     <!-- End demo -->
  106.     <div class="demo-description">
  107.         <p>
  108.             Demonstrate how to use an accordion to structure products into a catalog and make
  109.             use drag and drop for adding them to a shopping cart, where they are sortable.</p>
  110.     </div>
  111.     <!-- End demo-description -->
  112. </body>
  113. </html>

Please help me to understand this subject.

Thanks to all!