需要针对初学者的可排序和序列化指导
您随处都可以找到有关如何使列表可排序的示例。但是,我需要将新订单发布到另一个页面。我必须监督一些愚蠢的事情,但经过 3 天后我仍然没有解决方案。 我有一个查询输出
然而,变量 sort_serialized 给出一个空字符串。这是我第一次使用 jQuery。任何帮助将不胜感激。 比安卡
You can find exemples everywhere about how to make a list sortable. But then, I need to post the new order to another page.I must oversee something stupid but after having passed 3 days on it I still don't have the solution.
I have an query output
<script>
$(function() {
$( "#ulsortable" ).sortable();
});
$('#frm-sort').submit(function(){
var sort_serialized = $("#ulsortable").sortable("serialize");
});
</script>
<form action="#request.site.webroot#/actions/act_writeneworder.cfm" method="post" id="frm-sort">
<input type="submit" name="save" id="save" value="save" />
<input type="hidden" name="sort_serialized" id="sort_serialized" value="" />
</form>
The variable sort_serialized however gives an empty string. This is my first experience with jQuery. Any help would be greatly appreciated.
Bianca
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据序列化文档:
您的列表项上有
id
属性吗?您是否已验证它们全部包含下划线并且格式正确?
According to the documentation for serialize:
Do you have
id
attributes on your list items?Have you verified all of them contain an underscore and are of the correct form?
您正在将变量 = 设置为序列化,而不是实际的隐藏字段,如果您设置隐藏字段值,会发生什么情况,
这里还有一个问题,其中包含有关将序列化列表发布到可能有用的另一个页面的更多信息。
jQuery:如何处理可排序的列表(' Serialize') 返回?
------------------ 这是一个适合您的示例 ------------------ ------------
您应该能够将其发布在 html 页面中,调整头部中的脚本和样式参考,它将 工作。当您单击该按钮时,它会将序列化列表放入文本框中。例如,移动几个项目后,我得到结果
这是代码。
You are setting a variable = to the serailization, but not the actual hidden field, what happens if you set the hidden field value using
also here is a question that has more information about posting a serialized list to another page that may be useful.
jQuery: What to do with the list that sortable('serialize') returns?
------------------ Here is an Example for you that works ---------------------------
You should be able to post this in an html page, adjust your Script and Style Refereneces in the head and it will work. When you click the button it will put the serialized list in the textbox. For example after moving a couple of Items, I get the result
Here is the code.