From 0af77f3f28ff79689083bb8be053f6428573175c Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Sun, 30 Jun 2013 23:53:14 -0400 Subject: [PATCH] fix some bugs with selected and kill button --- extras/hairlines.js | 10 +++++----- tests/hairlines.html | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/extras/hairlines.js b/extras/hairlines.js index 5252026..92bbc25 100644 --- a/extras/hairlines.js +++ b/extras/hairlines.js @@ -121,9 +121,6 @@ hairlines.prototype.createHairline = function(props) { self.hairlineWasDragged(h, event, ui); } // TODO(danvk): set cursor here - }) - .on('click', function() { - self.moveHairlineToTop(h); }); h = $.extend({ @@ -134,12 +131,15 @@ hairlines.prototype.createHairline = function(props) { }, props); var that = this; - $infoDiv.on('click', '.hairline-kill-button', function() { + $infoDiv.on('click', '.hairline-kill-button', function(e) { that.removeHairline(h); $(that).triggerHandler('hairlineDeleted', { xval: h.xval }); $(that).triggerHandler('hairlinesChanged', {}); + e.stopPropagation(); // don't want .click() to trigger, below. + }).on('click', function() { + that.moveHairlineToTop(h); }); return h; @@ -296,7 +296,7 @@ hairlines.prototype.click = function(e) { that.updateHairlineDivPositions(); that.updateHairlineInfo(); - this.updateHairlineStyles(); + that.updateHairlineStyles(); that.attachHairlinesToChart_(); $(that).triggerHandler('hairlineCreated', { diff --git a/tests/hairlines.html b/tests/hairlines.html index 759aa5b..8318602 100644 --- a/tests/hairlines.html +++ b/tests/hairlines.html @@ -266,7 +266,8 @@ }); // Select/Deselect hairlines on click. - $('.hairline-info').click(function() { + $(document).on('click', '.hairline-info', function() { + console.log('click'); var xval = $(this).data('xval'); var hs = hairlines.get(); for (var i = 0; i < hs.length; i++) { -- 2.7.4