Skip to content

Commit f5ee324

Browse files
committed
Fixing initial sizing for #189
1 parent 6135752 commit f5ee324

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

grails-app/assets/javascripts/forms-knockout-bindings.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -460,19 +460,24 @@
460460
var select2 = $parentColumn.find('.select2-container');
461461
function calculateWidth() {
462462
var columnWidth = $parentTable.width()*percentageWidth/100;
463-
select2.css('max-width', columnWidth+'px');
463+
if (columnWidth > 10) {
464+
select2.css('max-width', columnWidth+'px');
465+
}
466+
else {
467+
// The table is not visible yet, so wait a bit and try again.
468+
setTimeout(calculateWidth, 200);
469+
}
464470
}
465-
var debounce = null;
466471
resizeHandler = function() {
467-
clearTimeout(debounce);
472+
clearTimeout(calculateWidth);
468473
setTimeout(calculateWidth, 300);
469474
};
470475
$(window).on('resize', resizeHandler);
471476

472477
ko.utils.domNodeDisposal.addDisposeCallback(element, function() {
473478
$(window).off('resize', resizeHandler);
474479
});
475-
resizeHandler();
480+
setTimeout(calculateWidth, 100);
476481
}
477482

478483
}

0 commit comments

Comments
 (0)