Skip to content

Commit bfe143c

Browse files
committed
Added a refresh method.
Refresh method can be used to reset size on a parent container state change.
1 parent 10d5a88 commit bfe143c

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

js/ui.multiselect.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,34 @@ $.widget("ui.multiselect", {
131131
return false;
132132
});
133133
},
134+
135+
refresh : function() {
136+
137+
// reset dimensions
138+
this._setDimensions();
139+
140+
},
141+
134142
destroy: function() {
135143
this.element.show();
136144
this.container.remove();
137145

138146
$.Widget.prototype.destroy.apply(this, arguments);
139147
},
148+
149+
_setDimensions : function() {
150+
151+
// set dimensions
152+
this.container.width(this.element.width()+1);
153+
this.selectedContainer.width(Math.floor(this.element.width()*this.options.dividerLocation));
154+
this.availableContainer.width(Math.floor(this.element.width()*(1-this.options.dividerLocation)));
155+
156+
// fix list height to match <option> depending on their individual header's heights
157+
this.selectedList.height(Math.max(this.element.height()-this.selectedActions.height(),1));
158+
this.availableList.height(Math.max(this.element.height()-this.availableActions.height(),1));
159+
160+
},
161+
140162
_populateLists: function(options) {
141163
this.selectedList.children('.ui-element').remove();
142164
this.availableList.children('.ui-element').remove();

0 commit comments

Comments
 (0)