jquery ui table

来源:互联网 发布:在虚拟机安装mac系统 编辑:程序博客网 时间:2024/06/15 21:25

[代码] jquery ui sortable 实现table,row的拖动 跳至 [1]

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
01.// Return a helper with preserved width of cells  
02.       varfixHelper = function(e, ui) { 
03.           //console.log(ui)  
04.            ui.children().each(function() { 
05.                $(this).width($(this).width());    //在拖动时,拖动行的cell(单元格)宽度会发生改变。在这里做了处理就没问题了  
06.            }); 
07.           returnui; 
08.        }; 
09.          
10.         
11.        jQuery(function(){ 
12.            jQuery("#hrCalendar tbody").sortable({               //这里是talbe tbody,绑定 了sortable  
13.                helper: fixHelper,                  //调用fixHelper  
14.                axis:"y"
15.                start:function(e, ui){ 
16.                    ui.helper.css({"background":"#fff"})    //拖动时的行,要用ui.helper  
17.                   returnui; 
18.                }, 
19.                stop:function(e, ui){ 
20.                   //ui.item.removeClass("ui-state-highlight"); //释放鼠标时,要用ui.item才是释放的行  
21.                   returnui; 
22.                } 
23.            }).disableSelection(); 
24.        }) 
原创粉丝点击