0

jQuery UI中sortable的表单提交

 2 years ago
source link: https://www.nixonli.com/6275.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
jQuery UI中sortable的表单提交

jqueryUI库中提供了一些封装好的,性能也算是比较好的一些工具,比如排序:sortable

在做分类的时候,这个功能就有点好了,直接拿它来排序,但是大家都觉得sortable怎么提交呢?提交的时候怎么把ID和数据传过去呢?要知道这。。TMD只是一个li,连form都没有,怎么办?

其实也算是比较方便的

JavaScript代码

$('.xxx').sortable(function(){&

jqueryUI库中提供了一些封装好的,性能也算是比较好的一些工具,比如排序:sortable

在做分类的时候,这个功能就有点好了,直接拿它来排序,但是大家都觉得sortable怎么提交呢?提交的时候怎么把ID和数据传过去呢?要知道这。。TMD只是一个li,连form都没有,怎么办?

其实也算是比较方便的

JavaScript代码

$('.xxx').sortable(function(){    
	'update':function(event,ui){  
		var ids = $(this).sortable('toArray').toString();    
		$.post('xxx',{"id":ids},function(){    
			//..    
		})    
	}  
})  
$('.xxx').disableSelection();     

主要就那个sortable(‘toArray’),看了一下手册,默认是使用了id,所以偷懒的话,你就把你的信息扔在id里就OK了。虽然就html规范来说,id不能是数字,但是你可以自己组装,然后post过去的时候,再解析嘛。

就是这样简单

本文出自: http://www.neatstudio.com/show-2460-1.shtml


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK