3

I've got a strange problem on Firefox that seems not to happen on Safari.

There's a table with a set of rows, each one of which has it's own onclick and ondblclick events. When one of the objects is double-clicked, it fires first the onclick associated function (as expected), where another row (different from the one double-clicked) is deleted. Afterwards, the function associated with dblclick won't fire.

If I comment the line which removes the row (not the one clicked, as I said, but another one), then both the onclick and ondblclick events will fire... I attach you the code for both event functions:

ret.onclick = function(){
    // Trigger click event
    var evt = arguments[0] || window.event;
    self.signalClick(evt.target || evt.srcElement);

    if(elem == this.selected) return;

    if(self.selected != null){
        // Set list element to not selected
        var telem = document.getElementById(self.getChildID(self.selected['id']));
        telem.setAttribute('class', 'gui_list_uselected');

        // Remove previously selected element summary
        var telemexp = document.getElementById(self.getChildID(self.selected['id']) + '_exp');
        if(telemexp) telemexp.parentNode.removeChild(telemexp); // FAULTY LINE!
    }

    ret.setAttribute('class', 'gui_list_selected');
    self.selected = elem;

    // Add element summary to the list
    appendAfter(ret, self.drawSummary(elem));
};

ret.ondblclick = function(){
    // Trigger double click event
    var evt = arguments[0] || window.event;
    self.signalDblClick(evt.target || evt.srcElement);
};
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
gaspercat
  • 425
  • 5
  • 13
  • It's been solved. The problem was on the line "if(elem == this.selected) return;", it had to be self.selected, to refer to the class, not the DOM object... – gaspercat Apr 28 '12 at 13:42

1 Answers1

0

Firefox works correctly. According to the spec, onclick fires before ondblclick anyway. Check out this so answer to overcome that.

Community
  • 1
  • 1
Ilya Kharlamov
  • 3,698
  • 1
  • 31
  • 33