JQuery events get unbound when I delete and re-add them
<p>I'm creating a custom view with sorting capabilities and has something that almost works, except that once it sorts once the click events to the elements being sorted become unbound, likely as a result of how i remove the elements and re add them sorted.</p>

<p>Is there a better way to do this such that the 'children' keep the bound events?</p>

<pre><code>function sortcontainer(container, sortby)
{
 alert(container.data("sessionlist").datetimesort);
 var children = container.children();

 children.sort(function (a, b) {
  if (sortby == "datetime")
  {
   if (!$(a).attr("starttime"))
    return -1;
   else if (!$(b).attr("starttime"))
    return 1;
   else if (container.data("sessionlist").datetimesort)
    return $(a).attr("starttime") - $(b).attr("starttime");
   else
    return $(b).attr("starttime") - $(a).attr("starttime");

  }
 }); // End sort function

 container.empty();
 container.html(children);

 if (sortby == "datetime")
  container.data('sessionlist').datetimesort = !container.data('sessionlist').datetimesort;
}
</code></pre>
