Web-item shows up later than at document ready

So the issue I am having is when trying to bind a javascript function to a web-item, that I have placed in the “More” drop down menu under issue view, the web-item apparently does not exist yet. I am attempting the binding in AJS.$(document).ready. Right now I have a temporary solution that will simply try to set it again at 100 millisecond intervals until it succeeds or times out after a while. Needless to say this is not ideal and I would like to find a more permanent solution.

All of the code works, but the issue is simply time. Is there a better event to attempt the binding in?

There are 2 ways of handling it:

  • Use AJS.$('###').live('click', function(evt){...});
  • Bind the the dropdown click first and then bind to your event after that.

The first way isn’t that great for performance if everyone is doing it. The second way can have a race condition.

Thanks for the input. The feeling I am getting is there is no clean way to do what I want to do by JS functionality. I opted to go down the servlet route instead.