Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
209 views
in Technique[技术] by (71.8m points)

php - Jquery sortable list won't serialize, why?

I'm implementing a sortable list of images with jquery in a Zend Framework application. I just can't get the .sortable('serialize') method to return more than an empty string.

When I try with a few simple examples outside my application it works.

Does it matter that the snippet below is wrapped in various other and other tags. I think it shouldn't. The unordered list should be found just by the id, right?

HTML:

<ul id="mylist">
    <li id="1">
        <div>
            <img src="image_1.jpg" />
            <p class="value_item">some text</p>
        </div>
    </li>
    <li id="2">
        <div>
            <img src="image_2.jpg" />
            <p class="value_item">some text</p>
        </div>
    </li>
</ul>

JavaScript:

$(document).ready(function() {                 
    $('#mylist').sortable({ 
        update: function() {
            var order = $('#mylist').sortable('serialize');
            alert(order);
        }                         
    });
});
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

http://api.jqueryui.com/sortable/#method-serialize

If serialize returns an empty string, make sure the id attributes include an underscore. They must be in the form: "set_number" For example, a 3 element list with id attributes foo_1, foo_5, foo_2 will serialize to foo[]=1&foo[]=5&foo[]=2. You can use an underscore, equal sign or hyphen to separate the set and number. For example foo=1 or foo-1 or foo_1 all serialize to foo[]=1.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...