Rewriting .click on an element once used in jQuery
<p>The question is: how can I make it so that every time openZonePupup() is called, whatever is assigned to the .click function changes on every call because right now it only changes on the first call ofopenZonePupup() </p>

<p>Let me first try and explain what the program does through prose and examples. This is for an online course which is split up into units. once a unit is clicked on a box pops up asking the user if they want to do a lesson or an exercise and then the lesson and exercise button has a function attached, with specific variables related to that lesson or exercise, to it with the <code>.click</code> function. </p>

<p>The problem is that once one unit has been clicked upon and the specific variables in the function applied using the <code>.click</code> function, once this popup has been closed and the user clicks on another unit, it uses the same specific variables from the first time. Maybe looking at my code would help you better:</p>

<p>Popup HTML:</p>

<pre><code>&lt;div class="jqmWindow" id="dialog"&gt;
    &lt;a id="popupHide" href="javascript:;" onclick="$('#dialog').jqmHide();" style=""&gt;&lt;/a&gt;

    &lt;div id="zoneName"&gt;&lt;/div&gt;
        &lt;div id="buttons"&gt;
            &lt;a id="lessonButton" class="lessonButton"&gt;Lesson&lt;/a&gt;
        &lt;a id="exerciseButton" class="exerciseButton"&gt;Exercise&lt;/a&gt;
    &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>The function called when the link to the unit is clicked on. It applies the name to the popup html and sets the link to the lesson and exercise according to the variables specified, then after it shows the popup:</p>

<pre><code>function openZonePupup(name,juegoID,tipoID,lang,nivel) {
    $("#zoneName").html(name);

    $(".lessonButton").click(function () { 
    $('#dialog').jqmHide();
        abrirLeccion(juegoID,nivel);    
    });

    $(".exerciseButton").click(function () { 
        obreJoc(juegoID, tipoID, name);
        $('#dialog').jqmHide();
    });

    $('#dialog').jqmShow();
}
</code></pre>

<p>openZonePopup is called by the text for the unit, for example:  </p>

<pre><code>&lt;a href="javascript:;" onclick="abrirZonePopUp('Past Simple - Past Continuous ',8,2,'EN',1);"&gt;02&lt;/a&gt;
&lt;a href="javascript:;" onclick="abrirZonePopUp('Conjunctions',22,8,'EN',1);"&gt;14&lt;/a&gt;
</code></pre>

<p>I hope you understand, if not leave a comment and i'll respond asap, thanks for any help that you can give!</p>
