Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added a refresh method. #105

Open
wants to merge 2 commits into from

2 participants

@arhea

I needed the refresh method because when using the multiselect widget in a tabbed view the original tab is hidden and therefore has no width. So on the tab change I needed to reset the dimensions of the multiselect. So I converted the set dimensions logic to one method _setDimensions then call this method in the _create and refresh methods.

arhea added some commits
@arhea arhea Added a refresh method.
Refresh method can be used to reset size on a parent container state
change.
bfe143c
@arhea arhea Converted _create method dimensions to _setDimensions method b106174
@anitagraham

Thanks. Needed this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 23, 2011
  1. @arhea

    Added a refresh method.

    arhea authored
    Refresh method can be used to reset size on a parent container state
    change.
  2. @arhea
This page is out of date. Refresh to see the latest.
Showing with 23 additions and 8 deletions.
  1. +23 −8 js/ui.multiselect.js
View
31 js/ui.multiselect.js
@@ -56,14 +56,7 @@ $.widget("ui.multiselect", {
var that = this;
- // 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));
+ this._setDimensions();
if ( !this.options.animated ) {
this.options.show = 'show';
@@ -131,12 +124,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();
Something went wrong with that request. Please try again.