html5 - Bootstrap accordion open one at a time -
i have created accordion , in loop want 1 accordion open @ time not multiple one. have used data parent
attribute of bootstrap not working. kind of highly appreciated. want 1 accordion open @ 1 time. how achieve it. think i'm having problem because of each loop. there way solve ?
here code :
<?php if(!empty($tickets)) : ?> <?php foreach($tickets $ticket) : ?> <div class="panel-group-custom" id="#panels"> <div class="panel panel-default mb-0 no-border"> <div class="panel-heading.panel-heading-custom" > <h4 class="panel-title"> <div data-toggle="collapse" data-parent="#panels" data-target="#collapse<?php echo $ticket['supportticket']['id'] ?>" class="accordion-title"> <div class="row"> <div class="overflow-hidden"> <div class="col-md-2"> <span class="ticket-heading1" title="ticket id"><i class="fa fa-ticket" aria-hidden="true"></i> <?php echo $ticket['supportticket']['ticket_id']; ?> </span> </div> <div class="col-md-7"><span class="ticket-title"><?php echo $ticket['supportticket']['title'] ?></span></div> <div class="col-md-2"> <span class="ticket-heading2" title="ticket created on"><i class="fa fa-calendar" aria-hidden="true"></i> <?php $bdate = date_create($ticket['supportticket']['modified']); ?> <?php echo date_format($bdate,"d-m-y") ?> </span> </div> <div class="col-md-1"> <span class="accordion-down"> <i class="fa fa-chevron-down dropdown-toggle down-arrow2" aria-hidden="true"></i> </span> </div> </div> </div> </div> </h4> </div> <div id="collapse<?php echo $ticket['supportticket']['id'] ?>" class="panel-collapse collapse"> <div class="panel-body"> <div class="hidden-overflow ticket"> <div class="full-width hidden-overflow ticket-chat"> <p class="color-4 ticket-content"> <?php echo $ticket['supportticket']['description'] ?> </p> <?php if($ticket['supportticket']['status']>1) : ?> <p class="color-1 pull-right ticket-content"> <span class="resolution">feedback</span> <?php echo $ticket['supportticket']['resolution_text']; ?> <span class="ticket-updated"><span class="bolder"><i class="fa fa-clock-o" aria-hidden="true"></i> <?php $bdate = date_create($ticket['supportticket']['modified']); ?> <?php echo date_format($bdate,"d-m-y") ?> </span></span> </p> <?php endif ?> </div> <div class="full-width hidden-overflow mt-5"> <!-- <p class="ticket-close"><i class="fa fa-window-close" aria-hidden="true"></i> closed on <span class="bolder">17-aug-2017 </span></p>--> </div> </div> </div> </div> </div> </div> <?php endforeach ?> <?php else : ?> no records <?php endif ?>
try putting #panels
div outside foreach
loop - way in same group.
also, #panels
div should not have "#" sign in id.
<?php if(!empty($tickets)) : ?> <div class="panel-group-custom" id="panels"><!-- remove '#' here. --> <?php foreach($tickets $ticket) : ?> <div class="panel panel-default mb-0 no-border"> <div class="panel-heading panel-heading-custom" ><!-- , remove . here. --> <h4 class="panel-title"> <div data-toggle="collapse" data-parent="#panels" data-target="#collapse<?php echo $ticket['supportticket']['id'] ?>" class="accordion-title"> <div class="row"> <div class="overflow-hidden"> <div class="col-md-2"> <span class="ticket-heading1" title="ticket id"><i class="fa fa-ticket" aria-hidden="true"></i> <?php echo $ticket['supportticket']['ticket_id']; ?> </span> </div> <div class="col-md-7"><span class="ticket-title"><?php echo $ticket['supportticket']['title'] ?></span></div> <div class="col-md-2"> <span class="ticket-heading2" title="ticket created on"><i class="fa fa-calendar" aria-hidden="true"></i> <?php $bdate = date_create($ticket['supportticket']['modified']); ?> <?php echo date_format($bdate,"d-m-y") ?> </span> </div> <div class="col-md-1"> <span class="accordion-down"> <i class="fa fa-chevron-down dropdown-toggle down-arrow2" aria-hidden="true"></i> </span> </div> </div> </div> </div> </h4> </div> <div id="collapse<?php echo $ticket['supportticket']['id'] ?>" class="panel-collapse collapse"> <div class="panel-body"> <div class="hidden-overflow ticket"> <div class="full-width hidden-overflow ticket-chat"> <p class="color-4 ticket-content"> <?php echo $ticket['supportticket']['description'] ?> </p> <?php if($ticket['supportticket']['status']>1) : ?> <p class="color-1 pull-right ticket-content"> <span class="resolution">feedback</span> <?php echo $ticket['supportticket']['resolution_text']; ?> <span class="ticket-updated"><span class="bolder"><i class="fa fa-clock-o" aria-hidden="true"></i> <?php $bdate = date_create($ticket['supportticket']['modified']); ?> <?php echo date_format($bdate,"d-m-y") ?> </span></span> </p> <?php endif ?> </div> <div class="full-width hidden-overflow mt-5"> <!-- <p class="ticket-close"><i class="fa fa-window-close" aria-hidden="true"></i> closed on <span class="bolder">17-aug-2017 </span></p>--> </div> </div> </div> </div> </div> <?php endforeach ?> </div><!-- end #panels (moved after foreach) --> <?php else : ?> no records <?php endif ?>
here working version php stripped out: https://jsfiddle.net/ytcw2sot/
Comments
Post a Comment