I'm trying to make a confirmation popup before user submits the form with CodeIgniter but the trigger/submit part is not working. It asks for confirmation but doesn't submits the form.
My HTML:
<?php
echo form_open(site_url("action"), array('id' => "order" , )) ?>
<input type="text" class="form-control" name="anything" value="">
<button type="submit" id="btn-submit" class="btn btn-danger" class="form-control">Submit</button>
<?php echo form_close() ?>
And Here's the Javascript
$('#btn-submit').on('click',function(e){
e.preventDefault();
var form = $(this).parents('form');
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false
}, function(isConfirm){
if (isConfirm) form.submit();
});
});
I've also tried targeting/selecting form id instead button but same issue. Resources are loaded properly.