diff --git a/js/icon_select.js b/js/icon_select.js index f832fe6c4..804581557 100644 --- a/js/icon_select.js +++ b/js/icon_select.js @@ -29,6 +29,7 @@ $(function() this.oLabel = $(''+sLabel+''); this.oButton = $(''); this.oButton.prepend(this.oLabel).prepend(this.oImg); + this.oButton.click(function(event, ui) { me._on_button_clicked(event, ui); }); this.element.after(this.oButton); this.element.addClass( "itop-icon-select" ).button(); this.element.bind( "reverted.itop-icon-select", function(ev, data) { @@ -72,6 +73,13 @@ $(function() var iWidth = Math.max(250, this.oButton.width()); this.oMenu = this.oButton.menu({ content: sMenu, callback: function(data) {me._on_icon_selection(data);}, showSpeed: 0, maxHeight: 300, flyOut: true, width: iWidth, positionOpts: {posX: 'left', posY: 'top', offsetX: 0, offsetY: 0} }); }, + _on_button_clicked: function(event, ui) + { + // Adjust the position of the menu, in case the button was moved... + // The simpler is to kill and rebuild the menu !!! + KillAllMenus(); + this._create_menu(); + }, // events bound via _bind are removed automatically // revert other modifications here