jQueryUI Sortable, Resizable, cacheable
Today I had a very weird problem with jQuery UI, namely sortable doesn’t play nice when the sortable elements are also resizable. This means that if an element was resized, the placeholder had wrong size, despite the forcePlaceholderSize
was either true
or false
. However, fortunate enough, sortable has plenty of events available and one of this is onStart
(start
actually):
$('.sortableWrapper > *').resizable(); $('.sortableWrapper').sortable({ 'forcePlaceholderSize': true, 'start' : function(e, ui){ $(ui.placeholder).width( $(ui.item).width() ); // this is where magic happens } });
- Posted in:
- JavaScript,
- jQuery