Permalink
Browse files

Fixed major issue with WidgetButtons and its event subscriptions.

Fixes #2531449
  • Loading branch information...
1 parent c1b4db5 commit d342a5c43d8c608721a6c73611d541fff912f8f2 @ericf ericf committed Jan 26, 2012
Showing with 17 additions and 21 deletions.
  1. +17 −21 src/widget-buttons/js/Widget-Buttons.js
@@ -25,12 +25,7 @@ var BOUNDING_BOX = "boundingBox",
* @class WidgetButtons
* @param {Object} config User configuration object
*/
-function WidgetButtons(config) {
-
- Y.after(this._renderUIButtons, this, RENDER_UI);
- Y.after(this._bindUIButtons, this, BIND_UI);
- Y.after(this._syncUIButtons, this, SYNC_UI);
-}
+function WidgetButtons() {}
/**
* Static hash of default class names used for the inner <span> ("content"),
@@ -134,6 +129,12 @@ WidgetButtons.prototype = {
_buttonsArray : null,
_uiHandlesButtons: null,
+ initializer: function () {
+ Y.after(this._renderUIButtons, this, RENDER_UI);
+ Y.after(this._bindUIButtons, this, BIND_UI);
+ Y.after(this._syncUIButtons, this, SYNC_UI);
+ },
+
destructor: function () {
this._detachEventsFromButtons();
},
@@ -168,16 +169,8 @@ WidgetButtons.prototype = {
* @protected
*/
_bindUIButtons : function () {
-
- var self = this;
-
- this._uiHandlesButtons = [];
-
- Y.each(this._buttonsArray, function(o) {
- self._attachEventsToButton(o);
- });
this.after(BUTTON_CHANGE, this._afterButtonsChange);
-
+ this._attachEventsToButtons();
},
/**
@@ -186,7 +179,7 @@ WidgetButtons.prototype = {
* This method is invoked after bindUI is invoked for the Widget class
* using YUI's aop infrastructure.
* </p>
- * @method _bindUIButtons
+ * @method _syncUIButtons
* @protected
*/
_syncUIButtons : function () {
@@ -202,7 +195,7 @@ WidgetButtons.prototype = {
/**
* Add a button to the existing set of buttons
*
- * @method _bindUIButtons
+ * @method addButton
* @param button {object} The object literal consisting of the button's properties and callback function
* @public
*/
@@ -278,8 +271,12 @@ WidgetButtons.prototype = {
* @method _attachEventsToButton
* @protected
*/
- _attachEventsToButton : function (o) {
- this._uiHandlesButtons.push(o.node.after(CLICK, o.cb, this));
+ _attachEventsToButtons : function (o) {
+ this._detachEventsFromButtons();
+
+ Y.each(this._buttonsArray, function (o) {
+ this._uiHandlesButtons.push(o.node.after(CLICK, o.cb, this));
+ }, this);
},
/**
@@ -289,10 +286,9 @@ WidgetButtons.prototype = {
* @protected
*/
_afterButtonsChange : function (e) {
- this._detachEventsFromButtons();
this._renderUIButtons();
- this._bindUIButtons();
this._syncUIButtons();
+ this._attachEventsToButtons();
},
/**

0 comments on commit d342a5c

Please sign in to comment.