Skip to content

Commit

Permalink
Fixed bug caused by assigning "thisObj" as global variable in Feature…
Browse files Browse the repository at this point in the history
…Track

constuctor, and subsequent use of thisObj in event handlers.  Revised
event handlinng so that "this" in the FeatureTrack event handler now
refers to the feature track (and same approach for DraggableFeatureTrack)
  • Loading branch information
GreggHelt2 committed Dec 6, 2010
1 parent a04fb0c commit 74456ae
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions js/FeatureTrack.js
Expand Up @@ -30,11 +30,12 @@ function FeatureTrack(trackMeta, url, refSeq, browserParams) {
this.trackMeta = trackMeta;
this.load(this.baseUrl + url);

thisObj = this;
var thisObj = this;
this.subfeatureCallback = function(i, val, param) {
thisObj.renderSubfeature(param.feature, param.featDiv, val,
param.displayStart, param.displayEnd);
};
this.featureClick = function(event) { thisObj.onFeatureClick(event); }
}

FeatureTrack.prototype = new Track("");
Expand Down Expand Up @@ -96,7 +97,8 @@ FeatureTrack.prototype.loadSuccess = function(trackInfo) {

/* Broken out of loadSuccess so that DraggableFeatureTrack can overload it */
FeatureTrack.prototype.onFeatureClick = function(event) {
var fields = thisObj.fields;
// var fields = thisObj.fields;
var fields = this.fields;
event = event || window.event;
if (event.shiftKey) return;
var elem = (event.currentTarget || event.srcElement);
Expand Down Expand Up @@ -447,11 +449,7 @@ FeatureTrack.prototype.renderFeature = function(feature, uniqueId, block, scale,
featDiv.target = "_new";
} else {
featDiv = document.createElement("div");
featDiv.onclick = this.onFeatureClick;
// Needed by DraggableFeatureTrack (which doesn't overload this function, renderFeature)
featDiv.onmouseover = this.onMouseOver;
featDiv.onmousedown = this.onMouseDown;
featDiv.onmouseup = this.onMouseUp;
featDiv.onclick = this.featureClick;
}

featDiv.feature = feature;
Expand Down

0 comments on commit 74456ae

Please sign in to comment.