So , i have one script that loads the bootstrap modal inside of my partial view :
$(document).ready(function () {
$(".empresa-texto-modal").click(function () {
var id = $(this).data("company_details");
id = id.trim();
$(".modal-content").load("/Acesso/_CompanyDetailsPartial?company_details=" + id, function () {
$("#EmpresaModal").modal("show");
});
});
});
My controller and view :
public async Task<IActionResult> _CompanyDetailsPartial(string company_details)
{
var checagem_company_details =await _context.lcr_LogLastAccess.ToListAsync();
var company_details_exists = checagem_company_details.Exists(x => x.logl_Company == company_details); //True : existe a empresa no banco
//False: n?o existe a empresa no banco
if (company_details_exists == false)
{
return NotFound("Error");
}
else
{
ViewBag.company_details = company_details;
return PartialView(await _context.lcr_LogLastAccess.ToListAsync());
}
}
<tbody>
@* Mostras todos os dados do banco de dados de forma filtrada por compania e data de acesso. *@
@{var EmpresaAgrupadaPorData = Model.GroupBy(x => x.logl_Company).Select(s => s.FirstOrDefault()).OrderByDescending(item => item.logl_AccessdDate).ToList();}
@foreach (var item in EmpresaAgrupadaPorData)
{
<tr>
<td>
<a class="empresa-texto-modal" data-company_details="@item.logl_Company">@Html.DisplayFor(modelItem => item.logl_Company)</a>
</td>
<td>@Html.DisplayFor(modelItem => item.logl_Name)</td>
<td>@Html.DisplayFor(modelItem => item.logl_Login)</td>
<td>@Html.DisplayFor(modelItem => item.logl_AccessdDate)</td>
</tr>
}
</tbody>
The problem is when i have a company name that comes from table EX: carrefour , and another company EX: carrefour e express my bootstrap modal doesnt work on the last...
question from:
https://stackoverflow.com/questions/65851322/script-that-loads-the-bootstrap-modal-bug 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…