On Click of edit, panel-body obviously will get opened at the same time i want to hide panel-heading
<div class="panel panel-default">
<div class="panel-heading row" id="first">
<div class="col-md-4">First Name</div>
<div class="col-md-4"><?php echo $row->first_name; ?></div>
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
<div class="col-md-4 profile-edit"> <i class="fa fa-pencil"></i> Edit</div>
</a>
</div>
<div id="collapseOne" class="panel-collapse collapse">
<div class="panel-body">
<div class="row">
<div class="col-md-7 col-md-offset-2 text-center">
<label class="col-md-4">First Name</label>
<div class="col-md-8">
<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
<input type ="text" name="first_name" id="first_name" class="form-control" value="<?php echo $row->first_name; ?>"/></br>
<input type="submit" value="Save" class="btn btn-success" style="width:70px;">
<button type="button" data-target="#collapseOne" data-toggle="collapse" class="btn btn-warning cancel-name">Cancel</button>
</div>
</div>
</div>
</div>
</div>
</div>
The easiest method would be to use jquery!
$(document).ready(function(){
$(".profile-edit").on("click", function(){
$(".panel-heading").hide();
});
});
This is just off the top of the head though, so may take some finesse.
Related
Bootstrap accordion is not working correctly.If i click on one accordion tab it is closing the other one and some times it is closing and opening again.For the first time it is working fine but for the next time its not working correctly.If i click on one tab it is closing the other one or else it will be opened by default after closing
<div class="col-lg-6">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Notify Users
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
<form>
<div class="row">
<div class="form-group">
<div class="col-lg-6">
<select id="selection" class="form-control">
<option>All Users</option>
<option>Metronomic</option>
<option>Fairfax Users</option>
</select>
</div>
<div class="col-lg-6">
<select id="selection" class="form-control">
<option>App Notify</option>
<option>Email</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label for="title">Title</label>
<input type="text" class="form-control" placeholder="Notification title here..." id="title">
</div>
<div class="form-group">
<label for="last">Sub Title</label>
<input type="text" class="form-control" placeholder="Notification sub title here..." id="sub-title">
</div>
<div class="form-group">
<label for="notificationcontent">Notification Content</label>
<textarea class="form-control" placeholder="" id="notificationcontent"></textarea>
</div>
<button type="submit" class="btn btn-primary">Send Notification</button>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="true" aria-controls="collapseTwo">
Notify Users
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body">
<form>
<div class="row">
<div class="form-group">
<div class="col-lg-6">
<select id="selection" class="form-control">
<option>All Users</option>
<option>Metronomic</option>
<option>Fairfax Users</option>
</select>
</div>
<div class="col-lg-6">
<select id="selection" class="form-control">
<option>App Notify</option>
<option>Email</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label for="title">Title</label>
<input type="text" class="form-control" placeholder="Notification title here..." id="title">
</div>
<div class="form-group">
<label for="last">Sub Title</label>
<input type="text" class="form-control" placeholder="Notification sub title here..." id="sub-title">
</div>
<div class="form-group">
<label for="notificationcontent">Notification Content</label>
<textarea class="form-control" placeholder="" id="notificationcontent"></textarea>
</div>
<button type="submit" class="btn btn-primary">Send Notification</button>
</form>
</div>
</div>
</div>
</div>
</div>
you wrongly assigned data-parent="#accordion", you have to assign this for Collapse div and use single parent <div id="accordion"></div>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<div class="col-lg-6">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="row">
<div class="panel panel-default col-md-6">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Notify Users
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne" data-parent="#accordion">
<div class="panel-body">
<form>
<div class="row">
<div class="form-group">
<div class="col-lg-12">
<select id="selection" class="form-control">
<option>All Users</option>
<option>Metronomic</option>
<option>Fairfax Users</option>
</select>
</div>
<div class="col-lg-12">
<select id="selection" class="form-control">
<option>App Notify</option>
<option>Email</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label for="title">Title</label>
<input type="text" class="form-control" placeholder="Notification title here..." id="title">
</div>
<div class="form-group">
<label for="last">Sub Title</label>
<input type="text" class="form-control" placeholder="Notification sub title here..." id="sub-title">
</div>
<div class="form-group">
<label for="notificationcontent">Notification Content</label>
<textarea class="form-control" placeholder="" id="notificationcontent"></textarea>
</div>
<button type="submit" class="btn btn-primary">Send Notification</button>
</form>
</div>
</div>
</div>
<div class="panel panel-default col-md-6">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" href="#collapseTwo" aria-expanded="true" aria-controls="collapseTwo">
Notify Users
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingTwo" data-parent="#accordion">
<div class="panel-body">
<form>
<div class="row">
<div class="form-group">
<div class="col-lg-12">
<select id="selection" class="form-control">
<option>All Users</option>
<option>Metronomic</option>
<option>Fairfax Users</option>
</select>
</div>
<div class="col-lg-12">
<select id="selection" class="form-control">
<option>App Notify</option>
<option>Email</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label for="title">Title</label>
<input type="text" class="form-control" placeholder="Notification title here..." id="title">
</div>
<div class="form-group">
<label for="last">Sub Title</label>
<input type="text" class="form-control" placeholder="Notification sub title here..." id="sub-title">
</div>
<div class="form-group">
<label for="notificationcontent">Notification Content</label>
<textarea class="form-control" placeholder="" id="notificationcontent"></textarea>
</div>
<button type="submit" class="btn btn-primary">Send Notification</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
Bootstrap Data toggle collapse is not working. Issue is that when click on second link then first link is not toggle collapse
**Fiddle**
Demo
Try it. Now if you click on second link then first link is collapse.
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
</head>
<body>
<div id="accordion">
<div class="card card-plain">
<div class="card-header" role="tab" id="heading1">
<a data-toggle="collapse" aria-expanded="true" aria-controls="collapse1" data-target="#collapse1">
Company Information
<i class="now-ui-icons arrows-1_minimal-down"></i>
</a>
</div>
<div id="collapse1" class="collapse show" role="tabpanel" aria-labelledby="heading1" data-parent="#accordion">
<div class="card-body">
<div class="row">
<div class="col-sm-6">
<label>Company Name</label>
<input class="form-control" id="comp_entity" name="comp_entity" type="text" placeholder="Company Name" value="">
</div>
<div class="col-sm-6">
<label>Business Unit / Division</label>
<input class="form-control" id="bus_unit_div" name="bus_unit_div" type="text" placeholder="Business Unit / Division" value="">
</div>
</div>
</div>
</div>
</div>
<div class="card card-plain">
<div class="card-header" role="tab" id="heading2">
<a class="collapsed" data-toggle="collapse" aria-expanded="false" aria-controls="collapse2" data-target="#collapse2">
Employee Information
<i class="now-ui-icons arrows-1_minimal-down"></i>
</a>
</div>
<div id="collapse2" class="collapse" role="tabpanel" aria-labelledby="heading2" data-parent="#accordion">
<div class="card-body">
<div class="row">
<div class="col-sm-6">
<label>Job title / role</label>
<input class="form-control" id="job_title" name="job_title" type="text" placeholder="Job Title / Role" value="">
</div>
</div>
<div class="row">
<div class="col-sm-6">
<label>Hours of Work</label>
<input class="form-control" id="hours_of_work" name="hours_of_work" type="text" placeholder="Hours of Work" onkeyup="this.value = this.value.replace(/[^0-9]/, '')" value="">
</div>
<div class="col-sm-6">
<label>Performance Rating</label>
<input class="form-control" id="perform_rating" name="perform_rating" type="text" placeholder="Performance Rating" value="">
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<label>Personnel (Staff) Number</label>
<input class="form-control" id="personal_staff_num" name="personal_staff_num" type="text" placeholder="Personnel (Staff) number" onkeyup="this.value = this.value.replace(/[^0-9]/, '')" value="">
</div>
</div>
</div>
</div>
</div>
</body>
</html>
otherwise
please remove class show in the first tab content div
from
<div id="collapse1" class="collapse show" role="tabpanel" aria-labelledby="heading1">
to
<div id="collapse1" class="collapse" role="tabpanel" aria-labelledby="heading1">
and it will work.
use 'in' instead of 'show' in below code
<div id="collapse1" class="collapse in" role="tabpanel" aria-labelledby="heading1">
Enter the value of state after press the enter key, opening the country accordion but my requirement is enter the value of state after press the enter key collapse should be hide or off please suggest me any one.
<!--1 pannel starts-->
<div class="panel panel-default">
<div class="panel-heading row">
<div class="col-md-4">Country</div>
<div class="col-md-4" id="ccountry"><?php
if (isset($c_country)) {
echo $c_country;
}
?>
</div>
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1">
<div class="profile-edit col-sm-4 col-xs-4 col-md-4 aj-textbone">
<?php if (empty($c_country[0]) || empty($c_country)): ?>
Add
<?php else: ?>
<i class="fa fa-pencil"></i> Edit
<?php endif; ?>
</div>
</a>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body">
<div class="row">
<div class="col-md-7 col-md-offset-2 text-center">
<label class="col-md-4">Country</label>
<div class="col-md-8">
<input name="country" id="country" type ="text" class="form-control"
value="<?= (isset($c_country)) ? $c_country : null; ?>"/><br>
<input type="hidden" name="save_bcountry" id="save_bcountry" value="<?= (empty($c_country[0]) || empty($c_country)) ? 'Save' : 'Update'; ?>">
<?php if (empty($c_country[0]) || empty($c_country)): ?>
<button type="submit" class="btn btn-success aj-text-btnbone" data-target="#collapse1" data-toggle="collapse">Save</button>
<?php else: ?>
<button type="submit" class="btn btn-success aj-text-btnbone" data-target="#collapse1" data-toggle="collapse">Update</button>
<?php endif; ?>
<button type="button" data-target="#collapse1" data-toggle="collapse" class="btn btn-warning cancel-name">Cancel</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!--1 pannel ends-->
<!--2 pannel starts-->
<div class="panel panel-default">
<div class="panel-heading row">
<div class="col-md-4">State</div>
<div class="col-md-4" id="cstate">
<?php
if (isset($c_state)) {
echo $c_state;
}
?>
</div>
<a data-toggle="collapse" data-parent="#accordion" href="#collapse2">
<div class="profile-edit col-sm-4 col-xs-4 col-md-4 aj-textbtwo">
<?php if (empty($c_state[0]) || empty($c_state)): ?>
Add
<?php else: ?>
<i class="fa fa-pencil"></i> Edit
<?php endif; ?>
</div>
</a>
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body">
<div class="row">
<div class="col-md-7 col-md-offset-2 text-center">
<label class="col-md-4">State</label>
<div class="col-md-8">
<input name="state" id="state" type ="text" class="form-control"
value="<?= (isset($c_state)) ? $c_state : null; ?>"/><br>
<input type="hidden" name="save_bstate" id="save_bstate" value="<?= (empty($c_state[0]) || empty($c_state)) ? 'Save' : 'Update'; ?>">
<?php if (empty($c_state[0]) || empty($c_state)): ?>
<button type="submit" class="btn btn-success aj-text-btnbtwo" data-target="#collapse2" data-toggle="collapse">Save</button>
<?php else: ?>
<button type="submit" class="btn btn-success aj-text-btnbtwo" data-target="#collapse2" data-toggle="collapse">Update</button>
<?php endif; ?>
<button type="button" data-target="#collapse2" data-toggle="collapse" class="btn btn-warning cancel-name">Cancel</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!--2 pannel ends-->
Add the following in your script
$('input').keydown(function(event){
if(event.keyCode == 13) {
event.preventDefault();
$(this).closest("div").find(".btn-success").trigger('click');
return false;
}
});
Explanation
First track the keydown for enter
Then find the closest submit button to trigger the submit function
Hope this will work for you. If is there anything else let us know...
I have 3 panels with the same width but sometimes not the same height next to each other. When the heights are the same, the panels so line up correctly and there is no weird top margin.
However, when the height differs, some panels get dragged down and start lining up with the panel body? The panel bodies are also not always the same height
My HTML structure looks like this:
<div class="wrapper" data-reactid=".0.1">
<div class="col-sm-4 list" data-reactid=".0.1.0">
<div class="panel panel-default" data-reactid=".0.1.0.0">
<div class="panel-heading clearfix" data-reactid=".0.1.0.0.0">
<h4 class="panel-title pull-left" data-reactid=".0.1.0.0.0.0">Melodic House</h4>
<button type="button" class="btn btn-default btn-sm pull-right" data-reactid=".0.1.0.0.0.1"><span class="glyphicon glyphicon-remove" aria-hidden="true" data-reactid=".0.1.0.0.0.1.0"></span></button><button type="button" class="btn btn-default btn-sm pull-right" data-reactid=".0.1.0.0.0.2"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true" data-reactid=".0.1.0.0.0.2.0"></span></button>
</div>
<ul class="list-group" data-reactid=".0.1.0.0.2">
...
</ul>
</div>
</div>
<div class="col-sm-4 list" data-reactid=".0.1.1">
<div class="panel panel-default" data-reactid=".0.1.1.0">
<div class="panel-heading clearfix" data-reactid=".0.1.1.0.0">
<h4 class="panel-title pull-left" data-reactid=".0.1.1.0.0.0">Deep House</h4>
<button type="button" class="btn btn-default btn-sm pull-right" data-reactid=".0.1.1.0.0.1"><span class="glyphicon glyphicon-remove" aria-hidden="true" data-reactid=".0.1.1.0.0.1.0"></span></button><button type="button" class="btn btn-default btn-sm pull-right" data-reactid=".0.1.1.0.0.2"><span class="glyphicon glyphicon-chevron-down" aria-hidden="true" data-reactid=".0.1.1.0.0.2.0"></span></button>
</div>
<div class="panel-body" data-reactid=".0.1.1.0.1">
<form class="form-horizontal" data-reactid=".0.1.1.0.1.0">
<div class="form-group" data-reactid=".0.1.1.0.1.0.0">
<label class="col-sm-6 control-label" data-reactid=".0.1.1.0.1.0.0.0">Min Duration (minutes)</label>
<div class="col-sm-6" data-reactid=".0.1.1.0.1.0.0.1"><input type="number" class="form-control" id="minDuration" value="0" data-reactid=".0.1.1.0.1.0.0.1.0"></div>
</div>
<div class="form-group" data-reactid=".0.1.1.0.1.0.1">
<label class="col-sm-6 control-label" data-reactid=".0.1.1.0.1.0.1.0">Max Duration (minutes)</label>
<div class="col-sm-6" data-reactid=".0.1.1.0.1.0.1.1"><input type="number" class="form-control" id="maxDuration" value="120" data-reactid=".0.1.1.0.1.0.1.1.0"></div>
</div>
<div class="form-group" data-reactid=".0.1.1.0.1.0.2">
<label class="col-sm-6 control-label" data-reactid=".0.1.1.0.1.0.2.0">Days old</label>
<div class="col-sm-6" data-reactid=".0.1.1.0.1.0.2.1"><input type="number" class="form-control" id="daysOld" value="60" data-reactid=".0.1.1.0.1.0.2.1.0"></div>
</div>
<div class="form-group" data-reactid=".0.1.1.0.1.0.3">
<label class="col-sm-6 control-label" data-reactid=".0.1.1.0.1.0.3.0">Query</label>
<div class="col-sm-6" data-reactid=".0.1.1.0.1.0.3.1"><input type="text" class="form-control" id="query" value="" data-reactid=".0.1.1.0.1.0.3.1.0"></div>
</div>
<div class="form-group" data-reactid=".0.1.1.0.1.0.4">
<label class="col-sm-6 control-label" data-reactid=".0.1.1.0.1.0.4.0">Sorting</label>
<div class="col-sm-6" data-reactid=".0.1.1.0.1.0.4.1">
<select class="form-control" id="sorting" data-reactid=".0.1.1.0.1.0.4.1.0">
<option value="hot" data-reactid=".0.1.1.0.1.0.4.1.0.0">Hot</option>
<option value="likes" data-reactid=".0.1.1.0.1.0.4.1.0.1">Likes</option>
<option value="plays" data-reactid=".0.1.1.0.1.0.4.1.0.2">Plays</option>
<option value="date" data-reactid=".0.1.1.0.1.0.4.1.0.3">Date</option>
</select>
</div>
</div>
<div class="form-group" data-reactid=".0.1.1.0.1.0.5">
<label class="col-sm-6 control-label" data-reactid=".0.1.1.0.1.0.5.0">Player Height</label>
<div class="col-sm-6" data-reactid=".0.1.1.0.1.0.5.1"><input type="number" class="form-control" id="height" value="166" data-reactid=".0.1.1.0.1.0.5.1.0"></div>
</div>
<div class="form-group" data-reactid=".0.1.1.0.1.0.6">
<label class="col-sm-6 control-label" data-reactid=".0.1.1.0.1.0.6.0">Track limit</label>
<div class="col-sm-6" data-reactid=".0.1.1.0.1.0.6.1"><input type="number" class="form-control" id="limit" value="10" data-reactid=".0.1.1.0.1.0.6.1.0"></div>
</div>
<button class="btn btn-default pull-right" type="button" data-reactid=".0.1.1.0.1.0.7">Update</button>
</form>
</div>
<ul class="list-group" data-reactid=".0.1.1.0.2">
...
</ul>
</div>
</div>
<div class="col-sm-4 list" data-reactid=".0.1.2">
<div class="panel panel-default" data-reactid=".0.1.2.0">
<div class="panel-heading clearfix" data-reactid=".0.1.2.0.0">
<h4 class="panel-title pull-left" data-reactid=".0.1.2.0.0.0">Tropical House</h4>
<button type="button" class="btn btn-default btn-sm pull-right" data-reactid=".0.1.2.0.0.1"><span class="glyphicon glyphicon-remove" aria-hidden="true" data-reactid=".0.1.2.0.0.1.0"></span></button><button type="button" class="btn btn-default btn-sm pull-right" data-reactid=".0.1.2.0.0.2"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true" data-reactid=".0.1.2.0.0.2.0"></span></button>
</div>
<ul class="list-group" data-reactid=".0.1.2.0.2">
...
</ul>
</div>
</div>
</div>
(Sorry for the React clutter)
How do I get them all to line up at the top instead of the bottom?
I was not able to reproduce this from your code snippet, but this behavior is observed when using display:table-cell, in such cases a vertical-align: top aligns them at the top.
I have a panel with 2 tabs and different content. However, when I do a col-md-8 in tab 1, that's carryingover into tab 2, I want tab 2 to start fresh. Here's my code:
<div class="col-md-12">
<div class="panel with-nav-tabs panel-default">
<div class="panel-heading">
<ul class="nav nav-tabs">
<li class="active">Quick</li>
<li>Advanced</li>
</ul>
</div>
<div class="panel-body">
<div class="tab-content">
<div class="tab-pane fade in active" id="tab1default">
<div class="col-md-8 col-md-offset-2">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for..." id="searchTerm" name="searchTerm" value='<?php echo $value; ?>' required>
<span class="input-group-btn">
<button class="btn btn-default" type="submit" name="action"><span class="glyphicon glyphicon-search"></span> Search</button>
</span>
</div><!-- /input-group -->
</div>
</div>
<div class="tab-pane fade" id="tab2default">
<div class="col-md-8 col-md-offset-2">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for..." id="searchTerm" name="searchTerm" value='<?php echo $value; ?>' required>
<span class="input-group-btn">
<button class="btn btn-default" type="submit" name="action"><span class="glyphicon glyphicon-search"></span> Search</button>
</span>
</div><!-- /input-group -->
</div>
</div>
</div>
</div>
</div>
</div>
I am not seeing anything unexpected here: http://bootsnipp.com/snippets/902Ep
Could you take a screenshot of the problem area?