From 74456ae2f0bf1a955340f7ad28dbd4332cc2079d Mon Sep 17 00:00:00 2001 From: Gregg Helt Date: Sun, 5 Dec 2010 18:03:08 -0800 Subject: [PATCH] Fixed bug caused by assigning "thisObj" as global variable in FeatureTrack 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) --- js/FeatureTrack.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/js/FeatureTrack.js b/js/FeatureTrack.js index 27bbc54ca8..44a3667a63 100644 --- a/js/FeatureTrack.js +++ b/js/FeatureTrack.js @@ -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(""); @@ -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); @@ -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;