Skip to content
This repository

Controlgroup fixes #5651

Merged
merged 1 commit into from over 1 year ago

2 participants

Przemyslaw Ciezkowski Gabriel "_|Nix|_" Schulhof
Przemyslaw Ciezkowski

Hi.
I found that refresh was called twice when creating controlgroup widget. First from method _setType() and then from _init(). I used _initialRefresh property to determine if options are set when widget is created. I've checked that changing type with $().controlgroup('option', 'type', 'vertical') still works :) There should probably be test added.
I also added some small performance fixes:

  • removed ui object
  • create legend wrapper only when it is needed
Gabriel "_|Nix|_" Schulhof gabrielschulhof merged commit 2138a09 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Feb 18, 2013
Przemyslaw Ciezkowski stforek Controlgroup: refresh was called twice when widget was created. Legen…
…d element is now created when it is needed.
2138a09
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 6 additions and 7 deletions. Show diff stats Hide diff stats

  1. +6 7 js/widgets/controlgroup.js
13 js/widgets/controlgroup.js
@@ -24,17 +24,14 @@ define( [ "jquery",
24 24
25 25 _create: function() {
26 26 var $el = this.element,
27   - ui = {
28   - inner: $( "<div class='ui-controlgroup-controls'></div>" ),
29   - legend: $( "<div role='heading' class='ui-controlgroup-label'></div>" )
30   - },
  27 + inner = $( "<div class='ui-controlgroup-controls'></div>" ),
31 28 grouplegend = $el.children( "legend" ),
32 29 self = this;
33 30
34 31 // Apply the proto
35   - $el.wrapInner( ui.inner );
  32 + $el.wrapInner( inner );
36 33 if ( grouplegend.length ) {
37   - ui.legend.append( grouplegend ).insertBefore( $el.children( 0 ) );
  34 + $( "<div role='heading' class='ui-controlgroup-label'></div>" ).append( grouplegend ).insertBefore( $el.children( 0 ) );
38 35 }
39 36 $el.addClass( "ui-corner-all ui-controlgroup" );
40 37
@@ -69,7 +66,9 @@ define( [ "jquery",
69 66 this.element
70 67 .removeClass( "ui-controlgroup-horizontal ui-controlgroup-vertical" )
71 68 .addClass( "ui-controlgroup-" + value );
72   - this.refresh();
  69 + if (!this._initialRefresh) {
  70 + this.refresh();
  71 + }
73 72 },
74 73
75 74 _setCorners: function( value ) {

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.