• Home
  • Jobs
  • Courses
  • Questions
  • Teachers
  • For business
  • ES/EN

0

46
Views
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 1 month ago ·

Juan Pablo Isaza

Answer question
Find remote jobs
Loading

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2022 PeakU Inc. All Rights Reserved.