Click event not getting triggered (probably a JSON issue....)

oh man… I have gotten so much help from folks here regardin my JSON issues in the last two days… for which I’m very very grateful, because I have learned a lot…
I have learned more JSON in the last two days than in all the time I’ve been trying to learn JSON…:wink:

so am humbly submitting one more question…

http://mayacove.com/dev/json/topics_lcl.html

test link at very top gets triggered, it shows all three values I want to show

but the links where it really should be happening, namely the “topic” links on the left, are simply not getting triggered at all, not even the alert, but I get no errors…

JS is here, http://mayacove.com/dev/json/js/topics_lcl.js
I moved the .click-binding code to the very bottom of the document.ready() wrapper, nothing changes…

what could this be?

thank you very much…

Hi Maya,

The problem is that you are inserting the topic links into your page dynamically, so they are ignoring the handlers that are registered when the DOM renders.

To address this you need to use event delegation, that is, attach the handler to an element that is present when the page loads.

Something like this:

$('body').on('click', '#left a', function(e){
  e.preventDefault();
  alert('test');
  $('section').hide();
  $('section').eq($(this).index('#left a')).slideDown();
});

oh my gosh, that’s right – the famous “on()”… :slight_smile:

thank you!!!

No problem.
Glad it worked :slight_smile: