JQUI Newb, Accordian unable to finish when appending..

JQUI Newb, Accordian unable to finish when appending..

Greetings,

I am a newb with Jquery UI.  Trying a side project that pulls in some JSON data, formats it, and displays it.

I have a working demo here (no JqueryUI):


I want to play with an accordian on the page.  Here is a demo:


My accordian Div is created in the DoM, and I have Jquery creating the content and appending it to the Div.  It appears jQueryUI is firing, and styling the accordian DIV, but perhaps not seeing the "appended content" because perhaps it doesn't exist yet?  Any suggestions?  Forgive me if I breach decorum here, I plead newbiness!

  1. <body>
  2. <header>
  3. <h1>State Jobs in Richland County,  SC</h1>
  4. </header>
  5. <div id="Accordion1"></div>
  6. <script>
  7.    
  8.        
  9.     $.ajax({
  10.             url: 'http://api.usa.gov/jobs/search.json?organization_ids=US-SC&size=100&query=Richland',
  11.             dataType: 'jsonp',
  12.             success:function (data) { 
  13. /*console.log(data)*/
  14. data.sort(function(a,b){
  15. return a.start_date.localeCompare(b.start_date)})
  16. data.reverse();
  17.             detChng = ["start",""];
  18. var i=0;
  19. var listid ="";
  20. var listid2=""; 
  21. var regres=""; 
  22.         $.each(data, function(index, element) {
  23. var re = /^.*(?=\/band|\/ band)/i
  24. var title =  element.position_title;
  25. var maxSal = element.maximum
  26. regres = title.match(re);
  27. if (regres !== null){
  28. title = regres;
  29. }
  30. detChng[1] = element.start_date;
  31. if (detChng[0] !== detChng[1]){
  32. i++;
  33. if (i !== 7){
  34. listid = "jobs" + i;
  35. listid2 = "#"+listid;
  36. /*console.log(i + " " +detChng[0] + "New!" + detChng[1] + " " + listid2);*/
  37. $('#Accordion1').append('<h3><a href="#">'+element.start_date+'</a></h3><div class="jobDatePanel" id="'+i+'"><ul id="'+ listid +'"></ul></div>');
  38. detChng[0] = detChng[1];
  39. }
  40. };

  41. if (maxSal > 70000) {
  42. $(listid2).append('<li class="higher"><a  href="' + element.url + '">' +title +'</a></li> ');
  43. } else {
  44. $(listid2).append('<li><a href="' + element.url + '">' + title +'</a></li> ');
  45. }
  46. return (i !== 7);
  47.             
  48.                           });   
  49.                              }
  50.                 });
  51.   
  52.         
  53.     
  54. </script>

  55. <script type="text/javascript">
  56. $(function() {
  57. $( "#Accordion1" ).accordion(); 
  58. console.log("Accordian Fired");
  59. });

  60. </script>

  61.  
  62. </body>