I need to pass object to my modal. For now I have something like this :
@for (int i = 0; i < @Model.Count; i++)
{
<div id="contentDiv" style="margin: 10px">
<div class="form-group">
<div>
DAY : @Model[i].Day.Day / Hour : @Model[i].Hour
</div>
<div class="form-group">
<button id="reservationButton" class="btn-default btn-lg" disabled="@Model[i].IsHourTaken()" onclick="@($"OpenModalPopUp('{i}')");">Book</button>
</div>
</div>
</div>
}
my js :
function OpenModalPopUp(id) {
$('#myModal').modal();
};
and my modal :
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Book this hour!</h4>
</div>
<div class="modal-body">
<div>
<div>
<div class="row">
<b>Day:</b>
<div class="col-lg-5">
<span class="reservationDay"> @Model[indexOftheDay].Day </span>
</div>
</div>
<div class="row">
<b>Hour:</b>
<div class="col-lg-5">
<span class="reservationHour"> @Model[indexOftheDay].Hour </span>
</div>
</div> (......)
My problem is here @Model[indexOftheDay].Day I dont know how to pass indexOftheDay to my modal.
Thanks in advance!
modalpartial view rendered in the main View? Do you create a modal for each item in yourModelor you have onemodaland you want update the modal based on the click?