2017-12-03 14:48:33 +08:00
|
|
|
@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
|
|
|
|
},
|
2017-12-03 14:48:33 +08:00
|
|
|
success: function (data) {
|
|
|
|
// console.log(data);
|
|
|
|
$(destContainer).replaceWith(data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-01-03 00:53:25 +08:00
|
|
|
$(document).ready(function() {
|
2017-12-03 14:48:33 +08:00
|
|
|
$(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);
|
|
|
|
});
|
2018-01-03 00:53:25 +08:00
|
|
|
});
|
2017-12-03 14:48:33 +08:00
|
|
|
</script>
|
|
|
|
@endsection
|