谁能告诉我我在这里缺少什么。
我的数据似乎总是空的,我做错了什么?
$(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:
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".
在您的 li
中添加一些带下划线的 ID,然后就可以了。
关于javascript - jQuery 可排序发布数据,但没有数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18902974/