jquery ui sortable serialize from children

Posted by FFish on Stack Overflow See other posts from Stack Overflow or by FFish
Published on 2010-05-06T23:09:07Z Indexed on 2010/05/07 4:28 UTC
Read the original article Hit count: 356

I want to send an Array with image paths and captions to a PHP script after I sorted the images. I can do 'serialize' or 'toArray' on the lists, but how to get the attributes from the img tag?

<ul class="gallery">
    <li id="li-1">
        <img src="tn/001.jpg" alt="first caption" />
    </li>
    <li mycaption="some caption" id="li-2">
        <img src="tn/002.jpg" alt="second caption with éèçà international chars" />
    </li>
</ul>

$(".gallery").sortable({
    update : function() {
        serial = $('.gallery').sortable('serialize');
        alert(serial);
        /* $.ajax({
            url: "sort.php",
            type: "post",
            data: serial,
            error: function() {alert("theres an error with AJAX");}
        }); */
    }
});

© Stack Overflow or respective owner

Related posts about jquery-ui

Related posts about sortable