views:

47

answers:

1

Functions added to selectors using .live() are not working consistently in Google chrome extensions. For example, I have a simple function that looks like this:

$("#sampleSelectID").live('click', function() {
    alert("CLICKED!");
});

and the alert does not fire. If I debug the extension there are no javaScript errors. Strangely, if I place a break-point on this line in the debugger, it will occasionally fire, but even then it's inconsistent.

Are there any strange issues with using .live() and jquery in a chrome extension?

I should add that each of these selectors is applied to a select object in a form which lives in my extension's popup html file like this:

<li class="sampleClass">
      <form>
        <select id="sampleSelectID">
        </select>
      </form>
</li>
A: 

I changed the "click" listener to "change" and this worked perfectly. It seems that "click" doesn't happen at the appropriate time in Chrome extensions, though this code works fine in Safari extensions. Change seems like the more appropriate one to listen for anyway.

RJ Owen