Skip to content
Loading
  
  • }  
  •     
  •       class="modal-footer">    
  •         "button" class="btn btn-primary">Save changes    
  •         "button" class="btn btn-secondary" data-dismiss="modal">Close    
  •           
  •         
  •       
  •   
  • step 3: open model with script as soon as form is submitted.
    1. "text/javascript">    
    2. $(document).ready(function () {    
    3.     $( "#button" ).click(function() {    
    4.         $( "#form" ).submit();      
    5.         $('#myModal').modal('show');    
    6.     
    7.     });    
    8. });    
    9.   
    Note:- better is to use Ajax so that you could open model on success only.
     
    Method 2. keep the button as submit but prevent the behaviour
    1. $("#myform").submit(function(e) {    
    2.     
    3.         //prevent Default functionality    
    4.         e.preventDefault();    
    5.     
    6.         //get the action-url of the form    
    7.         var actionurl = e.currentTarget.action;    
    8.     
    9.         //do your own request an handle the results    
    10.         $.ajax({    
    11.                 url: actionurl,    
    12.                 type: 'post',    
    13.                 dataType: 'application/json',    
    14.                 data: $("#myform").serialize(),    
    15.                 success: function(data) {    
    16.                    $("#myModel").model('show');    
    17.                 }    
    18.         });    
    19.     
    20.     });  
    According to me , second method is better.
    +2
  • 0
    i still can't get that working. When i press the save button nothing happens,
    0