I'm using Mustache.js for a project, but I'm stuck trying to include a jQuery button inside a template.
I made a template to display the five candidates for my state's governor election. In a JSON, I included their name, photo and party affiliation. I load the data into this template:
{{ #governor }}
<div class="cand-{{ head }}">
<div class="head">
<img src="{{ picture }}">
</div>
<div class="bio">
<h5>{{ name }}</h5>
<i class='fa fa-circle' style='color: {{ color }}'></i> {{ party }}<br>
</div>
</div>
{{ /governor }}
Now, I want to include a jQuery button underneath the party line that will hide the other candidates and bring up a div with details that will close with another button nested within. However, the button doesn't work inside the Mustache template. It works fine outside. Here's my button code:
<button class="open-govA">Details</button>
<script>
$( ".open-govA" ).click(function() {
$( ".details-govA" ).show( "slow" );
$( ".cand-govB, .cand-govC, .cand-govD, .cand-govE").hide( "slow" );
});
$( ".close-govA" ).click(function() {
$( ".details-gov" ).hide( "slow" );
$( ".cand-govB, .cand-govC, .cand-govD, .cand-govE").show( "slow" );
});
</script>
How should I proceed?