JS Fiddle: http://jsfiddle.net/JF7PD/

I've been doing extensive work on this and I've just able almost got it fully working. The reason why I am asking for help now is that I don't have a clue why my newly added accordion(s) do not expand upon being clicked.

I've got a feeling it may be due to the newly added code as I was having problems using my code in the file so instead I looked at the source and copied the accordion level to be used and all appears to look fine apart from them not expanding.

Thank you for any help in advanced,

Best Regards, Tim

  • Unfortunately, questions related to programming are off-topic for this site. You might ask this over at Stack Overflow, but be sure to search the answers there and read their FAQ first.
    – dan
    Jun 10, 2014 at 11:16

1 Answer 1


Your code isnt very easy to read (it has a lot of code not relevant to the question), but I'm guessing it's because of the event binding.

You can not bind events to elements that don't exists:

$('a').on('click', function(){ alert('clickety'); });
<div id="I_Will_Get_Anchors_via_Ajax"></div>

This will not fire when the anchors are clicked, because they dont exist yet. To fix this, you need to defer the event to something that does exist:

$('#I_Will_Get_Anchors_via_Ajax').on('click', 'a', function(){ alert('clickety'); });
<div id="I_Will_Get_Anchors_via_Ajax"></div>

In your case you don't load it via AJAX, but via the append function with html in it, but it's the same principle.

  • Sorry about there being unrelevant code in my fiddle @Martijn I was meant to be continuing until this occurred. To clarify, is this fiddle somewhat I need to do?
    – Tyler
    Jun 10, 2014 at 8:10
  • You also removed the relevant code now (the accordion and sortable), but I think my solution still stands :)
    – Martijn
    Jun 10, 2014 at 8:31
  • Oh no, that fiddle I replied with is not mine, I found it via a Google Search as I know nothing about Ajax so I'm trying to find out about it.
    – Tyler
    Jun 10, 2014 at 8:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.