I have a modal that Users can use to input Trips fields. One of the fields is a Multiple Photo upload input field. So when a user edits a trip, all the photos show up for that trip inside that modal. Users can them delete 1 photo at a time inside the modal.
The problem is when I hit that button to delete the photo, it redirects me back to that page, but the modal goes away. And thats kind off annoying, especially if you want to delete another photo or something.
What would be the correct way to keep that modal from closing after a redirect.
Here is my modal (Shortened):
<div class="modal fade" id="siteMessage" tabindex="-1" role="dialog" aria-labelledby="siteMessage">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">×</span></button>
<h4 class="modal-title" id="title">Some Trip Name Here</h4>
</div>
<div class="modal-body" id="body">
{{ Form::model( $trip, ['route'=>['user.listings.trips.create',$listing->slug], 'method'=>'POST', 'id' => 'trip_form', 'files' => true ]) }}
<!-- Add Trip Photos -->
<div class="form-group">
<label for="photos[]" class="control-label">Photos</label>
<input class="form-control" name="photos[]" type="file" id="photos[]">
</div>
<div class="col-md-12 no-padding">
@foreach( $trip->photos as $key => $photo )
<div class="col-xs-6 col-sm-6 col-md-4">
<img src="{{$photo->url}}" alt="{{$photo->name}}" class="img-responsive">
<a href="{{ route('user.listings.trip.photo.destroy',[$listing->slug,$photo->id]) }}" class="pull-right">
<i class="fa fa-trash" style="color: red;"></i>
</a>
</div>
@endforeach
</div>
{{ Form::close() }}
</div>
</div>
</div>
</div>
And this is my delete method:
public function deletePhoto(Request $request, $id) {
Photo::where('id', $id)->first()->delete();
return redirect()->back();
}
This is my request URL when I delete a photo
http://mywebsite.com/listings/expedition-wild-2/trips/photos/2456/destroy