jQuery listeners for html panels

What is the recommended way for attaching jQuery listeners to html panels in scripted dashboards? We add a panel to the top of our page, with custom html fields and later want to bind listeners to these fields. If we add the listener binding to the same script, it tries to attach before the page is rendered.

As an example, we add an element:

dropdown += "<div>";
dropdown += "<div id=\"filters\" style=\"margin-top:10px\"><b>Filters: </b></div>"

and later, as part of the same scripted dashboard, call:

function setupListener(currentXmlHttpRequests){
  $(document).unbind("DOMNodeInserted");
  $(document).ready(function(e){
      var element = document.getElementById("filters");
	      while(element.childNodes.length > 1)
		  element.removeChild(element.lastChild);
      ...
   }
}

For this trivial example, element is null
I’ve tried using $(window).on("load", function(e){..} but that never seems to trigger.