amircx wrote:
> im trying to see some working online examples of sortable plugin and
> its seems there is no such thing execept the offical website.. .why
> pepole dont use it?

This is not online, but is very basic and you can quickly try it out. I was 
a bit confused with this at first too due to the lack of any sortable 
example that would do a POST or GET request to the server. It is not 
complicated but would certainly be even easier and more popular if there was 
a working example.

A simple sortable list that does a POST request to the server where PHP or 
some other serverside language can grab the data. (On this example the 
server output is shown in the #data-div after the request has completed). 
Please note that obviously you need to have also called jquery.js and 
interface.js (you can download a lighter sortables-only version from the 
interface website) in the HEAD of your html doc.

HTML:
--------


<ul id="sortme">
 <li id="27" class="sortitem">Lorem</li>
 <li id="44" class="sortitem">Foo</li>
 <li id="136" class="sortitem">Bar</li>
 <li id="19" class="sortitem">Ipsum</li>
</ul>

<div id="data" style="background-color: #CCCCCC; padding: 15px; border: 
solid 1px #999;">
</div>


JQUERY:
-----------

$(document).ready(
 function()
 {
      $("#sortme").Sortable({
          accept : 'sortitem',
          onchange : function (sorted) {
              serial = $.SortSerialize('sortme');

    /*
    Instead of the $.ajax-call below, you could use these shorter funcs. In 
addition to the hash used by $.ajax, the SortSerialize method above also 
returns an object that can directly be used in the $().load and $.post/get 
functions:

    // $('#data').load("sortdata.php",serial.o.sortme);

    or

    // $.post("sortdata.php",serial.o.sortme, function(feedback){ 
$('#data').html(feedback); });


    */

     $.ajax({
                  url: "sortdata.php",
                  type: "POST",
                  data: serial.hash,
                  // complete: function(){},
                  success: function(feedback){ $('#data').html(feedback); }
                  // error: function(){}
              });

          }
      });
 }
);



SORTDATA.PHP
-------------------

<?php

// This can do anything it wants with the posted data which comes as an 
array. Here we just output it with print_r:
echo "DATA RECEIVED: <br>";
echo "<pre>";
print_r($_POST);
echo "</pre>";
?>


HTH


-- 
Suni



_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to