phpvms/resources/views/admin/pireps/script.blade.php

40 lines
1.1 KiB
PHP
Raw Normal View History

@section('scripts')
<script>
function changeStatus(values) {
var destContainer = '#pirep_' + values.pirep_id + '_container';
$.ajax({
url: '/admin/pireps/' + values.pirep_id + '/status',
data: values,
type: 'POST',
2018-01-03 00:50:41 +08:00
headers: {
'x-api-key': PHPVMS_USER_API_KEY
},
success: function (data) {
// console.log(data);
$(destContainer).replaceWith(data);
}
});
}
$(document).ready(function() {
$(document).on('submit', 'form.pirep_submit_status', function (event) {
console.log(event);
event.preventDefault();
var values = {
pirep_id: $(this).attr('pirep_id'),
new_status: $(this).attr('new_status')
};
console.log(values);
console.log('Changing PIREP ' + values.pirep_id + ' to state ' + values.new_status);
//var destContainer = '#pirep_' + pirep_id + '_container';
//$.pjax.submit(event, destContainer, { push: false, maxCacheLength: 0 });
changeStatus(values);
});
});
</script>
@endsection