mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
Updates to AJAX forms and adding autofill function to the event form when adding things via AJAX
This commit is contained in:
@@ -138,9 +138,17 @@
|
||||
jQuery(document).ready(function () {
|
||||
jQuery(document).on('click', '.modal-href', function (e) {
|
||||
e.preventDefault()
|
||||
modaltarget = jQuery(this).data('target')
|
||||
modalobject = "";
|
||||
jQuery('#modal').load(jQuery(this).attr('href'), function (e) {
|
||||
jQuery('#modal').modal();
|
||||
});
|
||||
jQuery('#modal').on('hide.bs.modal', function(e) {
|
||||
if(modaltarget != "" && modalobject != "") {
|
||||
jQuery(modaltarget).val(modalobject[0]['pk']);
|
||||
jQuery(modaltarget+'-input').val(modalobject[0]['fields']['name']);
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
@@ -10,5 +10,16 @@
|
||||
<div class="modal-footer">
|
||||
{% block footer %}{% endblock %}
|
||||
</div>
|
||||
<script>
|
||||
$('.modal-content form').on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
data = $(this).serialize();
|
||||
action = $(this).attr('action');
|
||||
console.log(action)
|
||||
$.post(action, data, function(resp) {
|
||||
$('#modal').html(resp);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user