knockout-sortable
knockout-sortable copied to clipboard
Added helper function to fix table widths when dragging
When dragging table rows the widths of the cells compress to content and loose their set values. I have added a helper function to the sortable options to fix the widths.
sortable.options.helper = function(e, ui) {
ui.children().each(function() {
$(this).width($(this).width());
});
return ui;
};
This is a great addition. Please accept it!
It would be nice to restrict this in some way to tables, so it doesn't need to run for every sortable all of the time.
@nicholasjackson Would you mind me giving it a go and adapting your PR to be restricted to tr
elements? Unless, of course, you'd like to re-submit yourself. Just asking since I'd love to see this supported.
I suppose it's simply a matter of:
Edit - removed the element query since, rather obviously, nothing else could/should be inside a tr
:
sortable.options.helper = function(e, ui) {
if (ui.is('tr')) {
ui.children().each(function() {
$(this).width($(this).width());
});
}
return ui;
};