EDIT:
I narrow down the problem and i found that if I have: plain input tag without MVC RAZOR then it work as expected
<input type="text" class="hiddenid2" /> //WORKED
but if i have : (does not work)
@Html.Editor("id", "", new { htmlAttributes = new { @class = "hiddenId2" } })
or
@Html.Editor("id", "", new { @class = "hiddenId2" })
then it does not work
END UPDATE
This is driving me crazy after going through line by line and everything seems correct but I'm not sure what else do I need to do here.
The problem I'm having is:
I'm passing the Id to the modal popup so I have two modal popup with different Ids & class name. The First modal popup works and it does pass the Id to modal popup but the second modal popup does not pass the id.
First Modal:
//View Link
<a href="/Home/Employee/@item.Id" data-id="@item.Id"
data-toggle="modal" data-target="#myModal"
class="modalLink">Load Employee</a>
View:
@using (Html.BeginForm("Employee", "Home", FormMethod.Post))
{
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Record</h4>
</div>
<div class="modal-body">
@Html.Hidden("id", "", new { @class = "hiddenid" })
</div>
<div class="modal-footer">
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
}
JQuery:
$(.modalLink").click(function () {
var passedID = $(this).data('id');
$('#id').val(passedID);
$(".modal-body .hiddenid").val(passedID);
});
Second Modal:
//View Link
<a href="/Home/Employer/@item.Id" data-id="@item.Id"
data-toggle="modal" data-target="#myModal2"
class="modalLink2">Load Employer</a>
View:
@using (Html.BeginForm("Employer", "Home", FormMethod.Post))
{
<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Record</h4>
</div>
<div class="modal-body">
@Html.Hidden("id", "", new { @class = "hiddenid" })
</div>
<div class="modal-footer">
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
}
JQuery:
$(.modalLink2").click(function () {
var passedID = $(this).data('id');
$('#id').val(passedID);
$(".modal-body .hiddenid").val(passedID);
});