I am trying to display a modal in an accordion but whenever I click on the modal button, the screen becomes grey and the modal ends up not showing.
This is my code:
#if(isset($data))
<div class="panel-group" id="accordion">
#foreach($data as $datum)
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#{{$datum['id']}}">
{{ucfirst($datum['username'])}}</a>
</h4>
</div>
<div id="{{$datum['id']}}" class="panel-collapse collapse">
<div class="panel-body">
Current balance: {{$datum['wallet']['balance']}} <br>
<button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#{{$datum['id']}}">Transfer</button>
<!-- Modal -->
<div id="{{$datum['id']}}" class="modal fade in" role="dialog" >
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Transfer Funds</h4>
</div>
<div class="modal-body">
<div class="col-md-3">
<label>Amount</label>
<input type="number" name="amount" class="form-control" placeholder="Amount to be transferred">
</div>
<input type="text" name="sub_agent" value="{{$datum['username']}}">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
#endforeach
</div>
#endif
You're using the same id="{{$datum['id']}}" for multiple HTML elements on your page:
<div id="{{$datum['id']}}" class="panel-collapse collapse">
...
<div id="{{$datum['id']}}" class="modal fade in" role="dialog">
Which means that these toggles:
<a data-toggle="collapse" data-parent="#accordion" href="#{{$datum['id']}}">
<button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#{{$datum['id']}}">Transfer</button>
Don't know what to target. Remember: in HTML, id attributes must be unique.
Try changing to the following:
<div id="{{$datum['id']}}_collapse" class="panel-collapse collapse">
...
<div id="{{$datum['id']}}_modal" class="modal fade in" role="dialog">
And adjust your targeting elements to:
<a data-toggle="collapse" data-parent="#accordion" href="#{{$datum['id']}}_collapse">
<button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#{{$datum['id']}}_modal">Transfer</button>
Related
I have an array of items that I'm using in Laravel (in the array, half are "parent items" and half are "child Items")
Say the array is 30 items, 15 of each type, I'm trying to get a result where I would have a single accordian header that says "Parent items" with the 15 parent items under the single header, then a single accordian header for the "Child items" with those 15 under it.
However, with my current code I'm getting the header over each individual item.
I understand this is because of the foreach, but I'm stumped on how exactly to achieve what I'm looking for and I just can't seem to get around the issue of the header over each item
What am I doing wrong here?
#foreach($items as $item)
#if($item['type'] == "Parent Item")
<div class="accordion" id="accordionExample">
<div class="card">
<div class="card-header" id="headingOne">
<h2 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Main/Parent Items
</button>
</h2>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordionExample">
<div class="card-body">
{{$item['Description']}}
</div>
</div>
</div>
</div>
#elseif($item['type'] == "Child Item")
<div class="accordion" id="accordionExample">
<div class="card">
<div class="card-header" id="headingTwo">
<h2 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="true" aria-controls="collapseTwo">
Sub/Child Items
</button>
</h2>
</div>
<div id="collapseTwo" class="collapse show" aria-labelledby="headingTwo" data-parent="#accordionExample">
<div class="card-body">
{{$item['Description']}}
</div>
</div>
</div>
</div>
#endif
#endforeach
You'll just need to do 2 loops, ie:
<div class="accordion" id="accordionExample">
<div class="card">
<div class="card-header" id="headingOne">
<h2 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Main/Parent Items
</button>
</h2>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordionExample">
#foreach($items as $item)
#if($item['type'] == "Parent Item")
<div class="card-body">
{{$item['Description']}}
</div>
#endif
#endforeach
</div>
</div>
</div>
<div class="accordion" id="accordionExample2">
<div class="card">
<div class="card-header" id="headingTwo">
<h2 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="true" aria-controls="collapseTwo">
Sub/Child Items
</button>
</h2>
</div>
<div id="collapseTwo" class="collapse show" aria-labelledby="headingTwo" data-parent="#accordionExample2">
#foreach($items as $item)
#if($item['type'] == "Child Item")
<div class="card-body">
{{$item['Description']}}
</div>
#endif
#endforeach
</div>
</div>
</div>
As a side note that id="accordionExample" on both elements is invalid, those should have unique ids.
I am trying to make a display while looping through items and displaying buttons. The buttons can open modals that display some data. I have tried to pass the data to the modal but it is just displaying the first iteration of the loops information and never get's updated. What do I need to do to make a modal for each iteration of my list?
#foreach ($forms as $form)
<div class="row">
<div class="col-lg-2">
<div style="float:left; padding-right: 10px;">
<a href="/form/{{$cuid}}/{{$form['cuBaseName']}}"
data-toggle="tooltip" title="Edit Fields"
><i class="fas fa-edit fa-2x"></i></a>
</div>
<div style="float:left; padding-right: 10px;">
<span data-toggle="modal" data-target="#copyFormModal">
<a href="#" data-toggle="tooltip" title="Copy"
><i class="fas fa-copy fa-2x"></i></a>
</span>
</div>
<div style="float:left; padding-right: 10px;">
<span data-toggle="modal" data-target="#deleteFormModal">
<a href="#" data-toggle="tooltip" title="Delete">
<i class="fas fa-trash-alt fa-2x"></i></a>
</span>
</div>
</div>
</div>
<hr>
#include('layouts.partials.modals.copyFormModal',['cuid'=>$cuid, 'cuBaseName'=> $form['cuBaseName']])
#include('layouts.partials.modals.deleteFormModal',['cuid'=>$cuid, 'cuBaseName'=> $form['cuBaseName']])
#endforeach
<!-- Modal -->
<div class="modal fade" id="deleteFormModal" tabindex="-1" role="dialog" aria-labelledby="deleteFormModal" aria-hidden="true" >
<div class="modal-dialog" role="document" style="max-width:900px;">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="exampleModalLabel">Delete Form</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Are you sure you want to delete form <b>{{$cuBaseName}}</b> from <b>{{$cuid}}</b>?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-success" data-dismiss="modal"
onclick='location.href="/forms/{{$cuid}}/{{$cuBaseName}}/delete"' >Delete</button>
</div>
</div>
</div>
</div>
Try this, add a unique #id to each modal window:
#foreach ($forms as $form)
<div class="row">
<div class="col-lg-2">
<div style="float:left; padding-right: 10px;">
<a href="/form/{{$cuid}}/{{$form['cuBaseName']}}"
data-toggle="tooltip" title="Edit Fields"
><i class="fas fa-edit fa-2x"></i></a>
</div>
<div style="float:left; padding-right: 10px;">
<span data-toggle="modal" data-target="#copyFormModal-{{$cuid}}">
<a href="#" data-toggle="tooltip" title="Copy"
><i class="fas fa-copy fa-2x"></i></a>
</span>
</div>
<div style="float:left; padding-right: 10px;">
<span data-toggle="modal" data-target="#deleteFormModal-{{$cuid}}">
<a href="#" data-toggle="tooltip" title="Delete">
<i class="fas fa-trash-alt fa-2x"></i></a>
</span>
</div>
</div>
</div>
<hr>
#include('layouts.partials.modals.copyFormModal',['cuid'=>$cuid, 'cuBaseName'=> $form['cuBaseName']])
#include('layouts.partials.modals.deleteFormModal',['cuid'=>$cuid, 'cuBaseName'=> $form['cuBaseName']])
#endforeach
<!-- Modal example -->
<div class="modal fade" id="deleteFormModal-{{$cuid}}" tabindex="-1" role="dialog" aria-labelledby="deleteFormModal" aria-hidden="true" >
<div class="modal-dialog" role="document" style="max-width:900px;">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="exampleModalLabel">Delete Form</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Are you sure you want to delete form <b>{{$cuBaseName}}</b> from <b>{{$cuid}}</b>?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-success" data-dismiss="modal"
onclick='location.href="/forms/{{$cuid}}/{{$cuBaseName}}/delete"' >Delete</button>
</div>
</div>
</div>
</div>
Hope it helps.
I have all my products in view:welcome.blade.php and The problem is how can I show modal with the details of a specific id?
<!-- End Product MEnu -->
<div class="row product__list">
#foreach($products as $product)
<!-- Start Single Product -->
<div class="col-md-3 single__pro col-lg-3 col-md-4 cat--1 col-sm-12">
<div class="product foo">
<div class="product__inner">
<div class="pro__thumb">
<a href="#">
<img src="{{ asset('storage/products/' . $product->image ) }}" width="270px" height="270px" alt="product images">
</a>
</div>
<div class="product__hover__info">
<ul class="product__action">
<li><a id="{{ $product->id }}" data-toggle="modal" data-target="#productModal" title="Quick View" class="quick-view modal-view detail-link viewDetails" href="#"><span class="ti-plus"></span></a></li>
<li><a title="Add TO Cart" href="cart.html"><span class="ti-shopping-cart"></span></a></li>
</ul>
</div>
<div class="add__to__wishlist">
<a data-toggle="tooltip" title="Add To Wishlist" class="add-to-cart" href="wishlist.html"><span class="ti-heart"></span></a>
</div>
</div>
<div class="product__details">
<h2>{{ $product->name }}</h2>
<ul class="product__price">
{{-- <li class="old__price">$16.00</li> --}}
<li class="new__price">₹ {{ $product->price }}</li>
</ul>
</div>
</div>
</div>
<!-- End Single Product -->
#endforeach
How can i show the details of a product in a modal?
Please Change Your data-target="#productModal{{ $product->id }}"
<div class="product__hover__info">
<ul class="product__action">
<li><span class="ti-plus"></span></li>
<li><a title="Add TO Cart" href="cart.html"><span class="ti-shopping-cart"></span></a></li>
</ul>
</div>
<div class="modal fade" id="productModal{{ $product->id }}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<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="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
{{$product->id}}
</div>
</div>
</div>
</div>
i created the bootstrap modal. the following images are albums cover images
<ul class="list-inline galleryItems">
#foreach($albums as $album)
<li data-toggle="modal" data-target="#myModal"><a href="#myGallery" data-slide-to=""><img src="{{ url('src/images/gallery/albums_cover',$album->photo->name) }}"><br>
Caption</a></li>
#endforeach
<!--end of thumbnails-->
and i had created the modal body and footer as follows
<div class="modal fade" id="myModal">
<br><br><br><br>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<div class="pull-left">My Gallery Title</div>
<button type="button" class="close" data-dismiss="modal" title="Close"> <span class="glyphicon glyphicon-remove"></span></button>
</div>
<div class="modal-body">
<!--begin carousel-->
<div id="myGallery" class="carousel slide" data-interval="false">
<div class="carousel-inner">
<div class="item active "> <img src="{{ url('src/images/gallery/albums_cover',$first_album->photo->name) }}" alt="item{{ $album->id }}" />
<div class="carousel-caption">
<h3></h3>
<p></p>
</div>
</div>
#foreach($albums as $album)
#foreach($album->photos as $photo)
<div class="item"> <img src="{{ url("src/images/gallery/album{$album->id}",$photo->name) }}" alt="" />
<div class="carousel-caption">
<h3></h3>
<p></p>
</div>
</div>
#endforeach
#endforeach
</div>
<!--Begin Previous and Next buttons-->
<a class="left carousel-control" href="#myGallery" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left"></span></a> <a class="right carousel-control" href="#myGallery" role="button" data-slide="next"> <span class="glyphicon glyphicon-chevron-right"></span></a>
<!--end carousel--></div>
<!--end modal-body--></div>
<div class="modal-footer">
<div class="pull-left">
<small>Photographs by Lorempixel.com</small>
</div>
<button class="btn-sm close" type="button" data-dismiss="modal">Close</button>
<!--end modal-footer--></div>
<!--end modal-content--></div>
<!--end modal-dialoge--></div>
<!--end myModal-->></div>
So, every time i click on any album, it shows me all the photos. i just want to display just the images that belongs to that folder
Thank you in advanced
when i click button and show Full information on model popup
<button type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#myModal" >
<i class="glyphicon glyphicon-zoom-in"></i>
</button><!-- Modal -->
the information will be show model popup
Try this
<button type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#myModal" >
<i class="glyphicon glyphicon-zoom-in"></i>
</button><div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Live Demo