您的位置:首页 > Web前端 > JQuery

jquery ui sortable 实现table,row的拖动。(Make Table Rows Sortable Using jQuery UI Sortable)

2011-09-29 16:15 916 查看
// Return a helper with preserved width of cells
var fixHelper = function(e, ui) {
//console.log(ui)
ui.children().each(function() {
$(this).width($(this).width());		//在拖动时,拖动行的cell(单元格)宽度会发生改变。在这里做了处理就没问题了
});
return ui;
};

jQuery(function(){
jQuery("#hrCalendar tbody").sortable({                //这里是talbe tbody,绑定 了sortable
helper: fixHelper,					//调用fixHelper
axis:"y",
start:function(e, ui){
ui.helper.css({"background":"#fff"})     //拖动时的行,要用ui.helper
return ui;
},
stop:function(e, ui){
//ui.item.removeClass("ui-state-highlight"); //释放鼠标时,要用ui.item才是释放的行
return ui;
}
}).disableSelection();
})


参考:http://www.foliotek.com/devblog/make-table-rows-sortable-using-jquery-ui-sortable/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: