This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function($) { | |
$('form[data-async]').on('submit', function(event) { | |
var $form = $(this); | |
var $target = $($form.attr('data-target')); | |
$.ajax({ | |
type: $form.attr('method'), | |
url: $form.attr('action'), | |
data: $form.serialize(), | |
success: function(data, status) { | |
$target.html(data); | |
} | |
}); | |
event.preventDefault(); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="#myModal" role="button" class="btn btn-large btn-primary" data-toggle="modal">Launch Demo Modal</a> | |
<!-- Bootstrap trigger to open modal --> | |
<div id="myModal" class="modal fade"> | |
<div class="modal-dialog"> | |
<div class="modal-content"> | |
<div class="modal-header"> | |
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> | |
<h4 class="modal-title">Confirmation</h4> | |
</div> | |
<div class="modal-body"> | |
<form class="form-horizontal well" data-async data-target="#result" action="<?php echo $base_url(); ?>modalcontroller/modal_response" method="POST"> | |
<fieldset> | |
<!-- form content --> | |
<label>Test</label><input type="text" name="text"/> | |
<input type="submit" name="submit" value="submit"> | |
</fieldset> | |
</form> | |
<!-- this is our target div where the response from the controller's method will show up --> | |
<div id="result"></div> | |
</div> | |
<div class="modal-footer"> | |
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> | |
<button type="button" class="btn btn-primary">Save changes</button> | |
</div> | |
</div> | |
</div> | |
</div> | |
<!-- end of test modal --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment