I have a list of items, and all of them will have a "click here for further info" link. With this link, I want to open a modal popup and display the details inside it. My problem is, how can I pass the id to the relevant modal popup.
At the moment I have the following code :-
Every item in the list will have the following:-
<a href="#" class="modal_link" data-id="@item.ExpId">Click here for more info.</a>
and in my jquery I have the following :-
var id = $(".modal_link").attr("data-id");
alert(id);
$(document).ready(function () {
$('.modal_block').click(function (e) {
$('#tn_select').empty();
$('.modal_part').hide();
});
$('.modal_link').click(function (e) {
$('.modal_part').show();
var context = $('#tn_select').load('/Experience/ShowExpDetail?id=' + id, function () {
initSelect(context);
});
e.preventDefault();
return false;
});
});
however the id is always undefined.
How can I pass this var?
Thanks for your help and time