Skip to content

Commit

Permalink
fix bug with faceted selector not fully initializing if no track meta…
Browse files Browse the repository at this point in the history
…data sources are defined
  • Loading branch information
rbuels committed Jun 5, 2012
1 parent a029205 commit 30fb67b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
20 changes: 18 additions & 2 deletions js/Model/TrackMetaData.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ dojo.declare( 'JBrowse.Model.TrackMetaData', null,
},this);

this.ready = true;
this.onReady();
this._onReady();
},

_itemSortFunc: function(a,b) {
Expand Down Expand Up @@ -556,11 +556,27 @@ dojo.declare( 'JBrowse.Model.TrackMetaData', null,
},this);
},

onReady: function( scope, func ) {
scope = scope || dojo.global;
func = dojo.hitch( scope, func );
if( ! this.ready ) {
this.onReadyFuncs.push( func );
return;
} else {
func();
}
},

/**
* Event hook called once when the store is initialized and has
* an initial set of data loaded.
*/
onReady: function() {},
_onReady: function() {
dojo.forEach( this.onReadyFuncs || [], function(func) {
func.call();
});
},

/**
* Event hook called after a fetch has been successfully completed
* on this store.
Expand Down
4 changes: 2 additions & 2 deletions js/View/TrackList/Faceted.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ dojo.declare( 'JBrowse.View.TrackList.Faceted', null,
this.renderInitial();

// once its data is loaded and ready
dojo.connect( this.trackDataStore, 'onReady', this, function() {
this.trackDataStore.onReady( this, function() {

// render our controls and so forth
this.renderSelectors();
Expand All @@ -81,7 +81,7 @@ dojo.declare( 'JBrowse.View.TrackList.Faceted', null,
});
});
});
dojo.connect( this.trackDataStore, 'onReady', this, '_updateFacetCounts' ); // just once at start
this.trackDataStore.onReady( this, '_updateFacetCounts' ); // just once at start

dojo.connect( this.trackDataStore, 'onFetchSuccess', this, '_updateGridSelections' );
dojo.connect( this.trackDataStore, 'onFetchSuccess', this, '_updateMatchCount' );
Expand Down

0 comments on commit 30fb67b

Please sign in to comment.