开发者

jQuery .live() function not working in Google Chrome extensions

Functions added to selectors using .live() are not working consistently in Google chrome extensions. For examp开发者_Python百科le, 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>


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜