Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

253
Visualizações
Append / Insert file name of document in Bootbox confirm delete text

I am using MVC 5 and utilizing Bootbox confirm modal dialog to get confirmation from the user, whether to delete the selected file or not.

My requirement is to append or insert the file name that the user has chosen to delete, in the confirmation dialog.

I have my ajax here, to get the file name, in my View :

 $.ajax({
          type: 'GET',
          url: '@Url.Action("GetFileName" , "Requirement")',
          data: { id: $ctrl.data('id') },
          success: function (result) {
          var filename = result;
          // alert(result);
          }
       });

In my controller, I am getting the passed Id from AJAX and returning the filename:

 public JsonResult GetFileName(int id)
 {
     RelatedDocument document = db.RelatedDocument.SingleOrDefault(w => w.DeactivatedDate == null & w.RelatedDocumentId == id);
     if (document != null)
     {
         return Json(document.DocumentName,JsonRequestBehavior.AllowGet);
     }
     return Json(new { success = false });
 }

I am getting the correct filename on my return AJAX call via alert and i am trying to get the filename from the variable that gets stored and trying to embed in the bootbox confirmation dilaog window:

bootbox.confirm("Are you sure you want to delete:  " +  filename + "  ?", function (result) {
                if (result) {
                    $.ajax({
                        type: 'GET',
                        url: '@Url.Action("DeleteFile", "Requirement")',
                        data: { id: $ctrl.data('id') },
                        success: function () {
                            $ctrl.closest('li').remove();
                            alertify.success('Deleted');
                        }
                    });
                }
                else {
                    alertify.error('Cancel');
                }
            });

But I am not getting the desired result or the filename embedded in the confirmation dialog.

What am I doing wrong ?

TIA.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda