Skip to content

Commit f2d6051

Browse files
committed
Fix wrong height on options box after a refresh
1 parent 0a729db commit f2d6051

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

js/jquery.selectric.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* /,'
1010
* /'
1111
*
12-
* Selectric Ϟ v1.4.6
12+
* Selectric Ϟ v1.4.7
1313
*
1414
* Copyright (c) 2013 Leonardo Santos; Dual licensed: MIT/GPL
1515
*
@@ -65,17 +65,19 @@
6565
function _start(){
6666
$wrapper.unbind(bindSufix);
6767
$original.unbind(keyBind + ' focusin');
68-
$outerWrapper.removeClass().addClass([classWrapper, $original.prop('class'), classDisabled].join(' '));
68+
$outerWrapper.removeClass().addClass(classWrapper + ' ' + $original.prop('class') + ' ' + classDisabled);
6969

7070
if (!$original.prop('disabled')){
7171
// Not disabled, so... Removing disabled class
7272
$outerWrapper.removeClass(classDisabled);
7373

7474
// Click on label and :focus on original select will open the options box
75-
$wrapper.bind(clickBind, function(e){ isOpen ? _close(e) : _open(e) });
76-
$original.bind(keyBind, _keyActions).bind('focusin' + bindSufix, function(e){ isOpen || _open(e) });
75+
$wrapper.bind(clickBind, isOpen ? _close : _open);
76+
$original.bind(keyBind, _keyActions).bind('focusin' + bindSufix, isOpen || _open);
7777

78-
$ul = $items.find('ul');
78+
// Remove styles from items box
79+
// Fix incorrect height when refreshed is triggered with fewer options
80+
$ul = $items.removeAttr('style').find('ul');
7981
$li = $ul.find('li').click(function(e) {
8082
e.stopPropagation();
8183
// The second parameter is to close the box after click
@@ -267,13 +269,14 @@
267269

268270
function _calculateHeight() {
269271
var visibleParent = $items.closest(':visible').children(),
270-
tempClass = pluginName + 'TempShow';
272+
tempClass = pluginName + 'TempShow',
273+
maxHeight = options.maxHeight;
271274

272275
// Set a temporary class on the hidden parent of the element
273276
visibleParent.addClass(tempClass);
274277

275278
// Set the dimensions
276-
$items.height() > options.maxHeight && $items.height(options.maxHeight);
279+
$items.height() > maxHeight && $items.height(maxHeight);
277280
$items.width($wrapper.outerWidth() - (options.border * 2));
278281

279282
// Remove the temporary class

js/jquery.selectric.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)