Exiting out of nested functions
<p>I have several elements in a class that have a click event attached to them. This calls a popup box with a link on it. The link makes an AJAX call to store the original element id in a database.</p>

<p>The problem is that if you open up the popup on one element and close it then do the same on another element, it will make two separate AJAX calls. When clicking on the link to hide the popup, I need a way to exit the original function that was called. This way it won't make more than one AJAX call at a time.</p>

<p>Below is a basic example of my problem:</p>

<pre><code>$(".ulElement").live('click', function(){
    $('#popup').css('visibility','visible');
    var elementNum = $(this).parent().attr('id');
    $('#popupLink1').click((function () { 
        //make Ajax call and send elementNum
    });
    $('#popopLink2').click((function () {
         $('#popup').css('visibility','hidden');
         //I need to exit the function that was called by ulElement here
    });
</code></pre>

<p>EDIT: This is my code simplified that I need working. Right now, it will still turn every element grey that I've clicked on.</p>

<pre><code>$(".position").live('click', function(event){
    $('#seatmenu').css('visibility','visible');
    var seatnum = $(this).parent().attr('id');

    $('.stand').css('visibility', 'visible');
    $(".menuhead").click(function(){
        clearMenu();               //this just hides the menu
        event.preventDefault();
    });


    $(".stand").click(function(){
        clearMenu();
        $('#'+seatnum).css('color','grey');
    });
});
</code></pre>
