Skip to content

Instantly share code, notes, and snippets.

@xhezairbey
Last active December 28, 2015 19:29
Show Gist options
  • Save xhezairbey/7550419 to your computer and use it in GitHub Desktop.
Save xhezairbey/7550419 to your computer and use it in GitHub Desktop.
Laravel Starter Site Fix Delete Post
@extends('admin.layouts.modal')
{{-- Content --}}
@section('content')
<!-- Tabs -->
<ul class="nav nav-tabs">
<li class="active"><a href="#tab-general" data-toggle="tab">General</a></li>
</ul>
<!-- ./ tabs -->
{{-- Delete Post Form --}}
<form id="deleteForm" class="form-horizontal" method="post" action="@if (isset($post)){{ URL::to('admin/blogs/' . $post->id . '/delete') }}@endif" autocomplete="off">
<!-- CSRF Token -->
<input type="hidden" name="_token" value="{{{ csrf_token() }}}" />
<input type="hidden" name="id" value="{{ $post->id }}" />
<!-- <input type="hidden" name="_method" value="DELETE" /> -->
<!-- ./ csrf token -->
<!-- Form Actions -->
<div class="control-group">
<div class="controls">
Delete Post
<element class="btn-cancel close_popup">Cancel</element>
<button type="submit" class="btn btn-danger">Delete</button>
</div>
</div>
<!-- ./ form actions -->
</form>
@stop
<!-- File truncated -->
<script type="text/javascript">
$(document).ready(function(){
$('.close_popup').click(function(){
parent.oTable.fnReloadAjax();
parent.jQuery.fn.colorbox.close();
return false;
});
$('#deleteForm').submit(function(event) {
var form = $(this);
$.ajax({
type: form.attr('method'),
url: form.attr('action'),
data: form.serialize()
}).done(function() {
parent.jQuery.colorbox.close();
parent.oTable.fnReloadAjax();
}).fail(function() {
});
event.preventDefault();
});
});
$('.wysihtml5').wysihtml5();
$(prettyPrint)
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment