Laravel-4-Bootstrap-Starter-Site
Laravel-4-Bootstrap-Starter-Site copied to clipboard
All Delete button not work with laravel 4
All delete button open the modal but with confirmation it returned to list page with no delete from the list and no delete from database.
public function postDelete($comment)
{
// Declare the rules for the form validation
$rules = array(
'id' => 'required|integer'
);
// Validate the inputs
$validator = Validator::make(Input::all(), $rules);
// Check if the form validates with success
if ($validator->passes())
{
$id = $comment->id;
$comment->delete();
// Was the comment post deleted?
$comment = Comment::find($id);
if(empty($comment))
{
// Redirect to the comment posts management page
return Redirect::to('admin/comments')->with('success', Lang::get('admin/comments/messages.delete.success'));
}
}
// There was a problem deleting the comment post
return Redirect::to('admin/comments')->with('error', Lang::get('admin/comments/messages.delete.error'));
}
I notice that as well , if you remove the class close_popup from the
<button type="submit" class="btn btn-danger close_popup">Delete</button>
in https://github.com/andrew13/Laravel-4-Bootstrap-Starter-Site/blob/master/app/views/admin/comments/delete.blade.php the delete would work but the popup will stay up
I'll confirm this later. Likely is fixed in develop branch.
I encountered the same issue, delete buttons not working, or happens as @dgafitescu noticed.
@andrew13 , do you have any news on this one? Thanks!
I see the same issue, i've been debugging it in depth and came to the same conclusion, by removing close_popup the postDelete action is performed and the server sees the incoming POST call. With that class enabled, on the server end it doesn't even receive a POST action from that delete popup page. I've tested it with Advanced REST client (chrome app) and when using the _token from the GET call + the id the delete does work when manually performed.
I already resolved it as following:
#Issue 1: when click outsite the colorbox, the colorbox is close but the parrent table is not updated.
Edit the file: views\admin\blogs\index.blade.php
Add script to $(".iframe").colorbox function
onClosed: function(){
oTable.fnReloadAjax();
}
to reload the table everytime we close the colorbox
#Issue 2: (this issue) Edit the file: views\admin\layouts\modal.blade.php
I use jquery to submit the form instead of manual submit the form. Add following code to $(document).ready() function
$(function() {
$('form').submit(function(event) {
var form = $(this);
$.ajax({
type: form.attr('method'),
url: form.attr('action'),
data: form.serialize()
}).done(function() {
// Optionally alert the user of success here...
parent.$.colorbox.close();
}).fail(function() {
// Optionally alert the user of an error here...
});
event.preventDefault(); // Prevent the form from submitting via the browser.
});
});
Note: if you use $('form').submit() it will submit and close all forms. That mean, when you submit edit/create form, it will close after submit too. So you should use id selector instead of, may be '#deleteForm'.
@andrew13 , do you have any news on this one? Thanks : ) Update us if it's resolved in Dev Branch please.
What I have done to make it work...
modal.blade.php
$(document).ready(function(){
$('.close_popup').click(function(){
parent.oTable.fnReloadAjax();
parent.jQuery.fn.colorbox.close();
return false;
});
$(function() {
$('#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);
@MartinOlsansky
It doesn't work for me. I added an id to my form with deleteForm. but it doesn't work...
The popup doesnt close after it's finished....
Thanks, Ara
@asivaneswaran you still need to remove close_popup in
as suggested by @dgafitescu above. This works for me fine.