Mustache Sending data back to Jquery
<p><strong>How can I send data from my mustache template back to JQuery?</strong></p>

<p>Hello.. This is my first time using a templating library. Most of my code works fine. But at this point, I need to load data from two separate sources. </p>

<p>1st source is a json file, loading all the users. I have username and ids.
2nd source require userid (that I loaded in first template). I want to get data from 1st source and render it on template..at the same time, I want to send these ids to ajax and load information from 2nd source and render it on the same template.
I just have to update 1  information from 2nd source . 
How do I send this span id to ajax function? If it was a button, I could simply use onclick event with id (working). But I have to update html. What do I do?<br>
P.S I also cant join both data in one json. The data is comming via API. </p>

<h1>my mustache template</h1>

<pre><code>&lt;script id="profile-template" type="text/template"&gt;
{#users}}

     Your user id is {{id}} &lt;br/&gt;
     Your name is {{name}}  &lt;br /&gt;

     Your other information &lt;span id="{{id}}-variable-text"&gt;this data has to be loaded from other api &lt;/span&gt;
    &lt;button onclick="updatetext({{id}});"&gt;Update text &lt;/button&gt;


{{/users}}
</code></pre>

<p>

<h1>My JQuery</h1>

<pre><code>&lt;script type="text/javascript"&gt;
$(document).ready(function(){
    $('#spanID-from-template').html(function(){
        // ajax 
    })
}
</code></pre>

<p></p>

<p>I'm using following code in ajax to name and ids from first source.
this is what happening in ajax success function()</p>

<pre><code>              var template = $("#profile-template").html();
              var html = Mustache.to_html(template, response);
              $('#users').append(html);
</code></pre>

<h1>A little hack I added to use onclick event to update text of id</h1>

<p>Check template above and the following jquery</p>

<pre><code>function updatetext(id){
 $("#"+id+"-variable-text").html("updated-text");

 }
</code></pre>