From: Dan Vanderkam Date: Mon, 1 Jul 2013 03:53:14 +0000 (-0400) Subject: fix some bugs with selected and kill button X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=0af77f3f28ff79689083bb8be053f6428573175c;p=dygraphs.git fix some bugs with selected and kill button --- 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++) {