jQuery可排序的帖子数据,但没有数据 [英] jQuery sortable post data, but there is no data
问题描述
有谁能告诉我这里缺少什么。
Can anyone tell me what I am missing here.
我的数据似乎总是空的,我做错了什么?
My data seems always to be empty, what am I doing wrong?
$(document).ready(function () {
$(".nav").sortable({
connectWith: ".nav",
axis: 'y',
update: function (event, ui) {
var data = $(this).sortable('serialize');
// POST to server using $.post or $.ajax
alert(data);
}
}).disableSelection();
});
推荐答案
按 sortable
API :
如果serialize返回一个空字符串,请确保id属性包含下划线。它们必须采用以下形式:set_number例如,具有id属性foo_1,foo_5,foo_2的3元素列表将序列化为foo [] = 1& foo [] = 5& foo [] = 2\" 。您可以使用下划线,等号或连字符来分隔集合和数字。例如foo = 1,foo-1和foo_1都序列化为foo [] = 1。
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", "foo-1", and "foo_1" all serialize to "foo[]=1".
将一些带有下划线的ID添加到 li
,然后罚款。
Add some ID's with underscores to your li
, then your fine.
演示: http://jsfiddle.net/tymeJV/vzQ2X/4/
这篇关于jQuery可排序的帖子数据,但没有数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!