HI,
Does form::submit work the same as form::button?
I am trying to add a jconfirm box. It pops up when I use form::button but then the form doesn't post and If I use form::submit it doesn't pop up but it submits the form.
I should say, that when I say the confirm box doesn't pop up, it actually does, it's just that it pops up really quickly and then continues to submit the form.
My view code
<tbody>
@foreach ($users as $user)
<tr>
<td>{{ $user->name }}</td>
<td>{{ $user->lastname }}</td>
<td>{{ $user->email }}</td>
<td>{{ $user->level }}</td>
<td>{{ link_to_route('users.edit', 'Edit', array($user->id), array('class' => 'confirm btn btn-info')) }}</td>
<td>
{{ Form::open(array('method' => 'DELETE', 'route' => array('users.delete', $user->id))) }}
{{ Form::button('Delete', array('class' => 'btn btn-danger delete', 'type' => 'submit')) }}
{{ Form::close() }}
</td>
</tr>
@endforeach
</tbody>
Javascript code
$(document).ready(function () {
$('.delete').on('click', function(){
$.confirm({
title: 'Confirm delete user?!',
content: 'Are you sure? Really?!',
buttons: {
confirm: function () {
$.alert('Okie Dokie!');
return_true();
},
cancel: function () {
$.alert('I guess not!');
return_false();
}
}
});
});
});
The rendered html for form::button is
<tr>
<td>asdf32rq3waf</td>
<td>sdfasdf</td>
<td>email</td>
<td>1</td>
<td><a href="http://localhost:8000/users/4/edit" class="confirm btn btn-info">Edit</a></td>
<td>
<form method="POST" action="http://localhost:8000/users/4/delete" accept-charset="UTF-8"><input name="_method" type="hidden" value="DELETE"><input name="_token" type="hidden" value="looooooooongkeyyyyyyyyyyyy">
<button class="btn btn-danger delete" type="submit">Delete</button>
</form>
</td>
</tr>
The rendered html for form::submit is
<tr>
<td>asdf32rq3waf</td>
<td>sdfasdf</td>
<td>email</td>
<td>1</td>
<td><a href="http://localhost:8000/users/4/edit" class="confirm btn btn-info">Edit</a></td>
<td>
<form method="POST" action="http://localhost:8000/users/4/delete" accept-charset="UTF-8"><input name="_method" type="hidden" value="DELETE"><input name="_token" type="hidden" value="verrrrrrrrrrryloooooongcode">
<input class="btn btn-danger delete" type="submit" value="Delete">
</form>
</td>
</tr>
echo Form::submit('Click Me!');
Note: Need to create a button element? Try the button method. It has the same signature as submit.
Thankyou,
Any help would be greatly appreciated.
Bobbie