Skip to content

Commit

Permalink
Added a refresh method.
Browse files Browse the repository at this point in the history
Refresh method can be used to reset size on a parent container state
change.
  • Loading branch information
arhea committed Nov 23, 2011
1 parent 10d5a88 commit bfe143c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions js/ui.multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,34 @@ $.widget("ui.multiselect", {
return false;
});
},

refresh : function() {

// reset dimensions
this._setDimensions();

},

destroy: function() {
this.element.show();
this.container.remove();

$.Widget.prototype.destroy.apply(this, arguments);
},

_setDimensions : function() {

// set dimensions
this.container.width(this.element.width()+1);
this.selectedContainer.width(Math.floor(this.element.width()*this.options.dividerLocation));
this.availableContainer.width(Math.floor(this.element.width()*(1-this.options.dividerLocation)));

// fix list height to match <option> depending on their individual header's heights
this.selectedList.height(Math.max(this.element.height()-this.selectedActions.height(),1));
this.availableList.height(Math.max(this.element.height()-this.availableActions.height(),1));

},

_populateLists: function(options) {
this.selectedList.children('.ui-element').remove();
this.availableList.children('.ui-element').remove();
Expand Down

1 comment on commit bfe143c

@anitagraham
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Needed this.

Please sign in to comment.