Reputation: 1189
So I have the following code :
{!! Form::open(['action'=>['AdminController@update',$upload->id], 'method'=>'POST']) !!}
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Filter
</button>
{{Form::hidden('_method','PUT')}}
{{Form::submit('Submit', ['class'=>'btn btn-success'])}}
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="/manage">Approve</a>
<a class="dropdown-item" href="/manage">Reject</a>
</div>
</div>
{!! Form::close()!!}
Instead of having the :
{{Form::hidden('_method','PUT')}}
{{Form::submit('Submit', ['class'=>'btn btn-success'])}}
I'd like to use the dropdown items
in order to submit data to the controller.
I tried having something like this :
{{Form::hidden('_method','PUT')}}
<a class="dropdown-item" onclick="{{Form::submit()}}" href="/manage">Approve</a>
The above didn't really work for me(actually it does work, but I don't want to submit with the button, but with the dropdown items
). Can I combine the Form::submit
and the dropdown items, such that when an item is clicked a submit
is made?
Upvotes: 0
Views: 1526
Reputation: 7509
Just add a bit of jQuery
$(".dropdown-item").click(function(e){
e.preventDefault();
$("form").submit();
});
Upvotes: 1