capturing jquery click event bubbling
<p>The web page I'm working on is a list of <code>candidate-tile</code>s which look like this (this is actually a <code>mustache</code> template:</p>

<pre><code>&lt;div class="candidate-tile"&gt;
    &lt;div class="candidate-image"&gt;
        &lt;img src="&lt;%= candidate.image %&gt;" width="50px" height=auto /&gt;
    &lt;/div&gt;
    &lt;div class="details"&gt;
        &lt;h3 class="candidate-name"&gt;&lt;%= candidate.name %&gt;&lt;/h3&gt;
        &lt;h6 class="candidate-dept"&gt;&lt;%= candidate.dept %&gt;&lt;/h6&gt;
        &lt;span class="label label-info"&gt;&lt;%= candidate.hostel %&gt;&lt;/span&gt;
    &lt;/div&gt;
    &lt;div class="checkbox"&gt;
        &lt;span class="check"&gt;&amp;#10003;&lt;/span&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>And I want to toggle a class when the checkbox is clicked. Something like this:</p>

<pre><code>$('.checkbox').click(function(){
    $(this).parent().toggleClass("candidate_selected");
});
</code></pre>

<p>But this doesn't seem to be working. How can I capture on the <code>checkbox</code> and make sure that the click event can be handled? </p>

<h2>UPDATE</h2>

<p>I just tested that there is some problem with click events in the <code>mustache</code> template. I'm using <code>sammy.js</code> to load the template. On the rest of the page (which is fixed and not being rendered using mustache / sammy) click events are working fine. But for some reason click events are not working on the part rendered by mustache / sammy. Does anyone have any idea what is going on? Is there something I can do to explain the situation better? Is sammy listening for events and not letting jquery handle it? </p>

<h2>ANOTHER UPDATE</h2>

<p>As far as I can understand the problem is that the <code>candidate-tile</code>s are not loaded when the  js file containing the <code>click</code> handler is loaded. Items are loaded later but by that time, I am guessing, all event registration has already happened and hence there are no events bound to  new DOM elements generated. Am I right in thinking so? If yes, what is the way out? </p>

<p>Thanks a lot!</p>
