I have a Foreach
in a table, I need as soon as the user clicks a line, open a modal with the data of the object contained in that row.
Foreach:
@foreach (PedidoModel pedido in @Model.Entidades)
{
<tr title="Clique para exibir detalhes" style="cursor:pointer" data-toggle="modal" data-target="#myModal">
<td style="text-align:center"><input type="checkbox"></td>
<td>@pedido.Pessoa.Nome</td>
<td>@pedido.DataEntrega</td>
<td></td>
<td>R$ @pedido.ValorTotal</td>
<td>@pedido.Endereco</td>
<td>
<span class="label label-success">@pedido.Status</span>
</td>
</tr>
}
When the user clicks on tr
I want to open a modal
that is in partialView
I tried to put partialView
inside foreach
and pass the model on the call, like this:
@Html.RenderPartial("~/Areas/Unidade/Views/Pedidos/_DetalhePedido.cshtml",pedido)
However, the Modal
appears on the page itself, without being modal
.
Before I had to pass the information to modal I would open it like this:
$("#myModal").on("show", function () {
$("body").addClass("modal-open");
}).on("hidden", function () {
$("body").removeClass("modal-open");
});
If anyone knows how to do this, I'll be grateful.