I have a modal
that renders a partialView
and I want to pass from this modal to screen view
main a dynamic list of listed objects that are selected by the user
$(".corpoPedido", parent.document).text($(".lista.active").each(function () { /*html*/}))
I want to insert the result into a div
into the view
principal with the class "request_body" all tr
that have both the "list" class and "active"
but I'm missing the syntax.
Can anyone help me?
EDITED:
in the modal:
@if (Model != null)
{
foreach (var item in Model)
{
<tr class="lista" data-codigo="@item.CODIGO" data-img="@item.img" data-desc="@item.Descricao"
data-un="@item.UN" data-grupo="@item.Grupo" data-preco="@item.preco" data-qnt="@item.Quantidade">
<td class="col-sm-1">
@Html.DisplayFor(modelItem => item.CODIGO)
</td>
<td class="col-sm-1">
@Html.DisplayFor(modelItem => item.img)
</td>
<td class="col-sm-3">
@Html.DisplayFor(modelItem => item.Descricao)
</td>
<td class="col-sm-1">
@Html.DisplayFor(modelItem => item.UN)
</td>
<td class="col-sm-2">
@Html.DisplayFor(modelItem => item.Grupo)
</td>
<td class="col-sm-2">
@Html.DisplayFor(modelItem => item.preco)
</td>
<td class="col-sm-2">
@Html.DisplayFor(modelItem => item.Quantidade)
</td>
</tr>
}
}
no js from this same page:
$(".corpoPedido", parent.document).text($(".lista.active").each(function () {
'<div class="row" data-img="'+$(this).attr('data-img')+'"> '+
'<div class="col-sm-1">' +
'<p>'+$(this).attr('data-codigo')+'</p>' +
'</div>' +
'<div class="col-sm-4">' +
'<p>'+$(this).attr('data-desc')+'</p>' +
'</div>' +
'<div class="col-sm-1">' +
'<p>'+$(this).attr('data-un')+'</p>' +
'</div>' +
'<div class="col-sm-1">' +
'<p>'+$(this).attr('data-grupo')+'</p>' +
'</div>' +
'<div class="col-sm-1">' +
'<p>'+$(this).attr('data-preco')+'</p>' +
'</div>' +
'<div class="col-sm-1">' +
'<p>' + $(this).attr('data-qnt') + '</p>' +
'</div>' +
'<div class="col-sm-1">' +
'<p class="total"> </p>' +
'</div>' +
'<div class="col-sm-1">' +
'<input type="submit" value="X" class="btn btn-danger cancelItem" />' +
'</div>'
}))
in main view
<div class="table well"style="margin-top:15px">
<div class="row linha">
<div class="col-sm-1">
<b>Código</b>
</div>
<div class="col-sm-4">
<b>Descrição</b>
</div>
<div class="col-sm-1">
<b>Und.</b>
</div>
<div class="col-sm-1">
<b>Grupo</b>
</div>
<div class="col-sm-1">
<b>Quantidade</b>
</div>
<div class="col-sm-1">
<b>Preço</b>
</div>
<div class="col-sm-1">
<b>Total</b>
</div>
<div class="col-sm-1">
</div>
</div>
<div class="row corpoPedido"></div>
</div>