Im trying to display more details about a restaurant when you click on a specific restaurant on a list. Currently I am displaying a list of restaurants in a list with a button saying more info. I want this information to show up in a modal
When I click on different restaurants in the list the information that is displayed in the modal is the same for each restaurant.
Here is the code that I'm using
@foreach (var item in Model)
{
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<center><h2 id="modalTitle" class="modal-title">@item.RestaurantName</h2></center>
</div>
<div class="modal-body">
<ul class="details">
<li class="modalListItem">
<i class="fa fa-info-circle fa-5" aria-hidden="true"></i>
<span>@item.RestaurantDescription</span>
</li>
<li class="modalListItem">
<i class="fa fa-envelope fa-5" aria-hidden="true"></i>
<span>@item.RestaurantEmailAddress</span>
</li>
<li class="modalListItem">
<i class="fa fa-clock-o fa-5" aria-hidden="true"></i>
<span>Opens from @item.OpeningTime.TimeOfDay - @item.ClosingTime.TimeOfDay</span>
</li>
<li class="modalListItem">
<i class="fa fa-list-alt fa-5" aria-hidden="true"></i>
<span>@item.FurtherDetails</span>
</li>
<li class="modalListItem">
<i class="fa fa-map-marker fa-5" aria-hidden="true"></i>
<span>@item.RestaurantAddress @Html.ActionLink("Directions", "GetDirections", new { id = item.RestaurantID }, new { @class = "btn btn-primary btn-xs" })</span>
</li>
<li class="modalListItem">
<i class="fa fa-bookmark-o fa-5" aria-hidden="true"></i>
<span>Would you like to make a reservation? @Html.ActionLink("Reserve", "CreateReservation", new { id = item.RestaurantID }, new { @class = "btn btn-success btn-xs" })</span>
</li>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
}
Here is the code which has the button
<table id="restaurantTable" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>Restaurant Name</th>
<th>Type Of Restaurant</th>
<th>Phone</th>
<th>Address</th>
<th>Options</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.RestaurantName)
</td>
<td>
@Html.DisplayFor(modelItem => item.RestaurantType)
</td>
<td>
@Html.DisplayFor(modelItem => item.RestaurantPhoneNo)
</td>
<td>
@Html.DisplayFor(modelItem => item.RestaurantAddress)
</td>
<td>
<button type="button" class="btn btn-info btn-xs" data-toggle="modal" data-target="#myModal">More info</button> |
@*@Html.ActionLink("More Info", "Details", new { id = item.RestaurantID }, new { @class = "btn btn-info btn-xs" }) |*@
@Html.ActionLink("Reserve", "CreateReservation", new { id = item.RestaurantID }, new { @class = "btn btn-success btn-xs" }) |
@Html.ActionLink("Directions", "GetDirections", new { id = item.RestaurantID }, new { @class = "btn btn-primary btn-xs" }) |
@Html.ActionLink("Review", "Review", new { id = item.RestaurantID }, new { @class = "btn btn-primary btn-xs" })
</td>
</tr>
}
</tbody>
</table>
}