Having issues using a scope in Jquery

74 views Asked by At

So I'm trying to pass a freemarker variable value (${item.uid}) on the click of a link in order to launch a modal with the same unique id value.

Although my functions can access the value of uid, when I run $('body').append($('div.disclaimer' + outerVar).remove()); the outerVar shows undefined.

JavaScript

var outerVar = uid;
$('body').append($('div.disclaimer' + outerVar).remove());

function showDisclaimer(uid) {
    var x = uid;
    $('div.disclaimer' + x).show();
}

function closeDisclaimer(uid) {
    var x = uid;
    // Clear the form and close the modal
    $('div.disclaimer' + x).hide();
}

HTML

<a onclick="showModal('${item.uid}')">Call Function</a>
<div class="modal${item.uid}" style="display:none;">
    <div class="content">
        Test Content Here
    </div>
</div>
0

There are 0 answers