fix some bugs with selected and kill button
authorDan Vanderkam <danvdk@gmail.com>
Mon, 1 Jul 2013 03:53:14 +0000 (23:53 -0400)
committerDan Vanderkam <danvdk@gmail.com>
Mon, 1 Jul 2013 03:53:14 +0000 (23:53 -0400)
extras/hairlines.js
tests/hairlines.html

index 5252026..92bbc25 100644 (file)
@@ -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', {
index 759aa5b..8318602 100644 (file)
       });
 
       // 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++) {