#1100 ✓help_request
david karapetyan

IE8 button click bug with Element#observe

Reported by david karapetyan | July 18th, 2010 @ 04:34 PM

In IE8 Element.observe has really weird behavior. Here's the snippet of the offending code, the pastie link and a link to a page that consistently reproduces the bug on my laptop with ie8.

//weird behavior in the latest prototype version with ie8
function originalHandler(event) {
    Event.stop(event); //this doesn't help either, the event still triggers newHandler
    var button = $('button');
    alert("first click");
    button.writeAttribute({onclick:null});
    function newHandler(event) {
        //this should only show up on the second click
        //but it shows up on the first click as well
        alert('second click');
    }
    button.observe('click',newHandler);
}

So to get the desired behavior I have to add an extra layer of indirection which seems really weird. Here's the pastie for the version that works on IE8 and the link to the page that behaves correctly on IE8 but requires an extra click on chrome and firefox.

function originalHandler(event) {
    Event.stop(event);
    var button = $('button');
    alert("first click");
    button.writeAttribute({onclick:null});
    var newHandler = function(ev) {
        button.stopObserving();
        button.observe('click',function() {alert("second click");});
    }
    button.observe('click',newHandler);
}

Comments and changes to this ticket

  • Tobie Langel

    Tobie Langel July 18th, 2010 @ 09:19 PM

    • State changed from “new” to “help_request”
    • Tag cleared.
    • Importance changed from “” to “Low”

    Looks like this issue was solved on Google groups. Closing as help request.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

Pages