views:

104

answers:

1

I'm developing a Firefox add-on and having a problem: onClick event does not work with xbl:inherits. Other attributes like value and src work well

Here is my code

Binding:

<binding id="CF-review">
    <content>
        <xul:vbox>
            <xul:label class="CF-review-url" xbl:inherits="onclick">[more]</xul:label>
        </xul:vbox>
    </content>
</binding>

Script:

function onReviewClick()
{
    alert("Something");
}

var elem = document.createElement("vbox");
elem.className = "CF-review";
elem.setAttribute("onclick", onReviewClick);

How can I set event onclick for xul:label element above?

A: 

Just a guess, don't know if this would work:

Add a <handler> in your XBL that just calls event.preventDefault if the event.target is anything other than the particular label you want the user to click on. Then when they click on that label, preventDefault won't be called and it will just work, by virtue of the fact that they added an onclick attribute.

MatrixFrog