Skip to content
Loading
    
  •                 
  •             
  •         
  •     
  •     
  • @Scripts.Render("~/bundles/jqueryval")    
  • @Scripts.Render("~/bundles/jquery")    
  • @Scripts.Render("~/bundles/bootstrap")    
  • @Styles.Render("~/Content/css")    
  •     
  • "text/javascript">    
  •     $(document).ready(function () {    
  •         $(".cancelButton").click(function (e) {    
  •             // Trigger(show) the modal.    
  •             $("#myModal13").modal({    
  •                 backdrop: 'static',    
  •                 keyboard: false    
  •             });    
  •     
  •             // Prevent the ActionLink from going to the controller.    
  •             e.preventDefault();    
  •         });    
  •                
  •         $('.btn-yes13').click(function() {    
  •             // Hide the modal.    
  •             $('#myModal13').modal('hide');    
  •     
  •             // CONCERN: HOW TO NOW FIRE THE ActionLink TO GO TO THE CONTROLLER METHOD?    
  •     
  •             // Return.    
  •             return true;    
  •         });    
  •     
  •         $(".btn-no13").click(function () {    
  •             $("#myModal13").modal("hide");    
  •     
  •             return false;    
  •         });    
  •     
  •         // Remove the modal once it is closed.    
  •         $("#myModal13").on('hidden.bs.modal', function () {    
  •             $("#myModal13").remove();    
  •         });     
  •     });       
  •   
  •     
  •                 
  •             
  •         
  • }    
  •     
  • class="modal fade" id="myModal13" role="dialog" display="none">    
  •     class="modal-dialog">    
  •         class="modal-content">    
  •             class="modal-body" style="padding:10px;">    
  •                 class="text-center">Any unsaved changes will not be processed if you cancel.       
  • Continue ?    
  •                 class="text-center">    
  •                     class="btn btn-info btn-yes13" href="/action/controller">Yes    
  •                     class="btn btn-default btn-no13" href="javascript:void();">No    
  •                     
  •                 
  •             
  •         
  •     
  •   
  •   
  •   
  •  
  •  
    +3
  • +2
    I don't want that ugly Standard Window's confirm.
    +2
  • +2
    Here's the AJAX, that I believe I cannot use: 
    1. $.ajax({  
    2.    type: 'POST',  
    3.    url: '@Url.Action("GetUserProfile", "UserProfile")',          
    4.    success: function (response) {  
    5.    // - Do a refresh.    
    6.    // - Re-render the view returned which is itself.  
    7.   
    8.    // 1st - remove the entire current view and then replace it with the same view sent back.   
    9.    // But how can I remove the current view as I would be removing the jQuery   
    10.    // code I am executing as it is part of the view?  
    11.   
    12.    $('div [class=zoneRemove']').remove();  
    13.   
    14.    var view = $("
      ").addClass('zoneRemove);  
    15.   
    16.    // Using the 'response'(the view) returned by the controller.  
    17.    view.append(response);  
    18.  },  
    19.  error: function (xhr, ajaxOptions, thrownError) {  
    20.    alert('Critical Error: something is wrong in the call to GetUserProfile for canclel changes! Status: ' + xhr.status + '. Error: ' + thrownError.toString() + '. Response Text: ' + xhr.responseText);            }  
    21.  });  
     
    +2
  • +2
    Sachin..that was helpful.
     
    2 things: I had to change the href to:
     
     
    On the No, I removed href="javascript:void();
     
    as the page was freezing and also, I still need to close the modal.
     
    So the final working solution is:
    1. class="panel-body">    
    2.     class="row">    
    3.         class="form-group">    
    4.             class="col-md-3">    
    5.                 "submit" value="Save" class="btn btn-primary saveButton" />    
    6.             
        
  •             class="col-md-3">    
  •                 class="btn btn-info cancelButton" value="Cancel Changes">    
  •                  
  •             
  •         
  •     
  •     
  • class="modal fade" id="myModal13" role="dialog" display="none">    
  •     class="modal-dialog">    
  •         class="modal-content">    
  •             class="modal-body" style="padding:10px;">    
  •                 class="text-center">Any unsaved changes will not be processed if you cancel.   Continue ?    
  •                 class="text-center">    
  •                     class="btn btn-info btn-yes13" href="/UserProfile/GetUserProfile">Yes    
  •                     class="btn btn-default btn-no13">No    
  •                     
  •                 
  •             
  •         
  •     
  •     
  • $(".cancelButton").click(function (e) {    
  •    // Trigger(show) the modal.    
  •    $("#myModal13").modal({    
  •       backdrop: 'static',    
  •       keyboard: false    
  •    });    
  • });    
  •     
  • $(".btn-no13").click(function () {    
  •    $("#myModal13").modal("hide");    
  •     
  •    return false;    
  • });    
  •     
  • $("#myModal13").on('hidden.bs.modal', function () {    
  •    $("#myModal13").remove();    
  • });  
  • +2